RustlerElixirFun. FunExecutionServer
(rustler_elixir_fun v0.4.0)
Copy Markdown
This GenServer listens for native code to send sets of functions + parameters to it.
It will then execute these functions (by calling apply(fun, parameters) on them),
and return the results to the native code.
iex> {:ok, pid} = RustlerElixirFun.FunExecutionServer.start_link([])
iex> RustlerElixirFun.Internal.apply_elixir_fun(pid, fn x -> x * 2 end, [10])
{:ok, 20}It is recommended to use a registered name (and start the process in a supervision tree) to make sure that you won't have to handle checking PIDs for aliveness in native code:
iex> {:ok, _} = RustlerElixirFun.FunExecutionServer.start_link([name: :my_fancy_worker_server])
iex> RustlerElixirFun.Internal.apply_elixir_fun(:my_fancy_worker_server, fn x -> x * 2 end, [42])
{:ok, 84} If you might call a function many times in short succession, or want to call many different functions,
it might make sense to use RustlerElixirFun.Pool instead.
Summary
Functions
Returns a specification to start this module under a supervisor.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.