Kernel.spawn_link
spawn_link
, go back to Kernel module for more information.
Specs
Spawns the given function, links it to the current process, and returns its PID.
Typically developers do not use the spawn
functions, instead they use
abstractions such as Task
, GenServer
and Agent
, built on top of
spawn
, that spawns processes with more conveniences in terms of
introspection and debugging.
Check the Process
module for more process-related functions. For more
information on linking, check Process.link/1
.
The anonymous function receives 0 arguments, and may return any value.
Inlined by the compiler.
Examples
current = self()
child = spawn_link(fn -> send(current, {self(), 1 + 2}) end)
receive do
{^child, 3} -> IO.puts("Received 3 back")
end
Specs
Spawns the given function fun
from the given module
passing it the given
args
, links it to the current process, and returns its PID.
Typically developers do not use the spawn
functions, instead they use
abstractions such as Task
, GenServer
and Agent
, built on top of
spawn
, that spawns processes with more conveniences in terms of
introspection and debugging.
Check the Process
module for more process-related functions. For more
information on linking, check Process.link/1
.
Inlined by the compiler.
Examples
spawn_link(SomeModule, :function, [1, 2, 3])