Module proc_lib
An implementation of the Erlang/OTP proc_lib interface.
Description
This module implements a strict subset of the Erlang/OTP proc_lib interface.
When spawning a single function, calling spawn/1 or spawn_link/1,
Erlang/OTP proc_lib sets initial_call to a tuple with a unique
atom determining where the function was created, for example
{some_module, '-work/3-fun-0-', 0}. AtomVM literaly calls erlang:apply/2
and therefore in these cases, initial_call is {erlang, apply, 2}.
Data Types
start_spawn_option()
start_spawn_option() = {min_heap_size, pos_integer()} | {max_heap_size, pos_integer()} | {atomvm_heap_growth, erlang:atomvm_heap_growth_strategy()} | link
Function Index
| init_ack/1 | Callback to signal that initialization succeeded. |
| init_ack/2 | Callback to signal that initialization succeeded. |
| initial_call/1 | Get the initial call for a given process or false
if it's not available. |
| spawn/1 | Restricted set of spawn options. |
| spawn/3 | Spawn a new process and initialize it. |
| spawn_link/1 | Equivalent to spawn_link(erlang, apply, [Fun, []]). |
| spawn_link/3 | Spawn and atomically link a new process and initialize it. |
| start/3 | Equivalent to start(Module, Function, Args, infinity). |
| start/4 | Equivalent to start(Module, Function, Args, Timeout, []). |
| start/5 | Start a new process synchronously. |
| start_link/3 | Equivalent to start_link(Module, Function, Args, infinity). |
| start_link/4 | Equivalent to start_link(Module, Function, Args, Timeout, []). |
| start_link/5 | Start a new process synchronously and atomically link it. |
| start_monitor/3 | Equivalent to start_monitor(Module, Function, Args, infinity). |
| start_monitor/4 | Equivalent to start_monitor(Module, Function, Args, Timeout, []). |
| start_monitor/5 | Start a new process synchronously and atomically link it. |
| translate_initial_call/1 | Get the initial call for a given process or {proc_lib, init_p, 5}
if it's not available. |
Function Details
init_ack/1
init_ack(Result::any()) -> ok
Result: result sent back to parent
Callback to signal that initialization succeeded.
init_ack/2
init_ack(Parent::pid(), Result::any()) -> ok
Parent: parent processResult: result sent back to parent
Callback to signal that initialization succeeded.
initial_call/1
initial_call(Process::pid()) -> {module(), atom(), [atom()]} | false
Process: process to get the initial call for
returns: false until we support process_info(Pid, dictionary)
Get the initial call for a given process or false
if it’s not available. Arguments are replaced with atoms.
spawn/1
spawn(Fun::fun(() -> any())) -> pid()
Equivalent to spawn(erlang, apply, [Fun, []]).
Restricted set of spawn options. monitor is not supported.
spawn/3
spawn(Module::module(), Function::atom(), Args::[any()]) -> pid()
Module: of the function to callFunction: to callArgs: arguments to pass to the function
Spawn a new process and initialize it.
spawn_link/1
spawn_link(Fun::fun(() -> any())) -> pid()
Equivalent to spawn_link(erlang, apply, [Fun, []]).
spawn_link/3
spawn_link(Module::module(), Function::atom(), Args::[any()]) -> pid()
Module: of the function to callFunction: to callArgs: arguments to pass to the function
Spawn and atomically link a new process and initialize it.
start/3
start(Module::module(), Function::atom(), Args::[any()]) -> any()
Equivalent to start(Module, Function, Args, infinity).
start/4
start(Module::module(), Function::atom(), Args::[any()], Timeout::timeout()) -> any()
Equivalent to start(Module, Function, Args, Timeout, []).
start/5
start(Module::module(), Function::atom(), Args::[any()], Timeout::timeout(), SpawnOpts::[start_spawn_option()]) -> any()
Module: the module in which the callbacks are definedFunction: to call for initializationArgs: arguments to pass to the functionTimeout: timeout for the initialization to be doneSpawnOpts: options passed to spawn. monitor is not allowed.
Start a new process synchronously. Wait for the process to call
init_ack/1,2 or init_fail/2,3.
start_link/3
start_link(Module::module(), Function::atom(), Args::[any()]) -> any()
Equivalent to start_link(Module, Function, Args, infinity).
start_link/4
start_link(Module::module(), Function::atom(), Args::[any()], Timeout::timeout()) -> any()
Equivalent to start_link(Module, Function, Args, Timeout, []).
start_link/5
start_link(Module::module(), Function::atom(), Args::[any()], Timeout::timeout(), SpawnOpts::[start_spawn_option()]) -> any()
Module: the module in which the callbacks are definedFunction: to call for initializationArgs: arguments to pass to the functionTimeout: timeout for the initialization to be doneSpawnOpts: options passed to spawn_link. monitor is not allowed.
Start a new process synchronously and atomically link it.
Wait for the process to call init_ack/1,2 or init_fail/2,3.
start_monitor/3
start_monitor(Module::module(), Function::atom(), Args::[any()]) -> any()
Equivalent to start_monitor(Module, Function, Args, infinity).
start_monitor/4
start_monitor(Module::module(), Function::atom(), Args::[any()], Timeout::timeout()) -> any()
Equivalent to start_monitor(Module, Function, Args, Timeout, []).
start_monitor/5
start_monitor(Module::module(), Function::atom(), Args::[any()], Timeout::timeout(), SpawnOpts::[start_spawn_option()]) -> any()
Module: the module in which the callbacks are definedFunction: to call for initializationArgs: arguments to pass to the functionTimeout: timeout for the initialization to be doneSpawnOpts: options passed to spawn_link. monitor is not allowed.
Start a new process synchronously and atomically link it.
Wait for the process to call init_ack/1,2 or init_fail/2,3.
translate_initial_call/1
translate_initial_call(Process::pid()) -> {module(), atom(), non_neg_integer()}
Process: process to get the initial call for
returns: {proc_lib, init_p, 5} until we support process_info(Pid, dictionary)
Get the initial call for a given process or {proc_lib, init_p, 5}
if it’s not available.