mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-14 17:04:48 +08:00
Apply review suggestions
This commit is contained in:
parent
254570ae95
commit
ff5cfce78f
2 changed files with 9 additions and 16 deletions
|
@ -78,19 +78,12 @@ defmodule LiveBook.Evaluator do
|
|||
|
||||
@impl true
|
||||
def init(_opts) do
|
||||
case Evaluator.IOProxy.start_link() do
|
||||
{:ok, io_proxy} ->
|
||||
# Use the dedicated IO device as the group leader,
|
||||
# so that it handles all :stdio operations.
|
||||
Process.group_leader(self(), io_proxy)
|
||||
{:ok, initial_state(io_proxy)}
|
||||
{:ok, io_proxy} = Evaluator.IOProxy.start_link()
|
||||
|
||||
:ignore ->
|
||||
:ignore
|
||||
|
||||
{:error, reason} ->
|
||||
{:stop, reason}
|
||||
end
|
||||
# Use the dedicated IO device as the group leader,
|
||||
# so that it handles all :stdio operations.
|
||||
Process.group_leader(self(), io_proxy)
|
||||
{:ok, initial_state(io_proxy)}
|
||||
end
|
||||
|
||||
defp initial_state(io_proxy) do
|
||||
|
@ -136,7 +129,7 @@ defmodule LiveBook.Evaluator do
|
|||
|
||||
defp eval(code, binding, env) do
|
||||
try do
|
||||
{:ok, quoted} = Code.string_to_quoted(code)
|
||||
quoted = Code.string_to_quoted!(code)
|
||||
{result, binding, env} = :elixir.eval_quoted(quoted, binding, env)
|
||||
|
||||
{:ok, result, binding, env}
|
||||
|
|
|
@ -43,7 +43,7 @@ defmodule LiveBook.Evaluator.IOProxy do
|
|||
"""
|
||||
@spec configure(pid(), pid(), Evaluator.ref()) :: :ok
|
||||
def configure(pid, target, ref) do
|
||||
GenServer.call(pid, {:configure, target, ref})
|
||||
GenServer.cast(pid, {:configure, target, ref})
|
||||
end
|
||||
|
||||
## Callbacks
|
||||
|
@ -54,8 +54,8 @@ defmodule LiveBook.Evaluator.IOProxy do
|
|||
end
|
||||
|
||||
@impl true
|
||||
def handle_call({:configure, target, ref}, _from, state) do
|
||||
{:reply, :ok, %{state | target: target, ref: ref}}
|
||||
def handle_cast({:configure, target, ref}, state) do
|
||||
{:noreply, %{state | target: target, ref: ref}}
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
|
Loading…
Add table
Reference in a new issue