Kernel.spawn

You're seeing just the function spawn, go back to Kernel module for more information.

Specs

spawn((() -> any())) :: pid()

Spawns the given function 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.

The anonymous function receives 0 arguments, and may return any value.

Inlined by the compiler.

Examples

current = self()
child = spawn(fn -> send(current, {self(), 1 + 2}) end)

receive do
  {^child, 3} -> IO.puts("Received 3 back")
end
Link to this function

spawn(module, fun, args)

View Source

Specs

spawn(module(), atom(), list()) :: pid()

Spawns the given function fun from the given module passing it the given args 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.

Inlined by the compiler.

Examples

spawn(SomeModule, :function, [1, 2, 3])