Erlang processes
Erlang processes are essential feature of the language. It's not an OS-based processes or threads. It's kinda internal type of concurrency. Erlang processes can run on multiple OS threads as well as within the same thread.
To create a process you should use spawn
function:
Proc = spawn(world, start, []).
The first parameter is module name, the second is function name, and the last parameter is process function argument list.
Return value is a process identifier. Usually you user process identifier to send messages into it. Messages are the way of communication between different Erlang processes. We will talk about Erlang messages in the next lesson.
An identifier of the current process can be obtained with self()
function.
To spawn a process on some function you have to export that function, even if you spawn a process within the same module.
Now, before continue, we should learn how to send and receive messages between Erlang processes.