Lightweight Processes
- spawn. spawn starts a process: microseconds to create, kilobytes of footprint, millions per node.
- Pids. A pid names a process: the address messages are sent to.
- Share nothing. Processes share nothing: each has its own heap, so no locks, no data races, ever.
Message Passing
- Send. The ! operator sends a message: Pid ! {order, 42}: asynchronous, never blocking the sender.
- Copy semantics. Messages are copied between heaps: isolation preserved even in passing.
- Any term travels. Any term can be a message: tuples with atoms tag meaning: {reserve, From, SeatId}.
Mailboxes and Receive
- Mailboxes. Each process owns a mailbox: messages queue until receive chooses them.
- receive. receive pattern-matches the mailbox: handling what fits, leaving what does not.
- Timeouts. receive takes an after clause: a timeout turning silence into a decision.
Before and after this level
- Before: Level 3: Data & Pattern Matching: Tuples, Maps and Records, Guards, Advanced Pattern Matching.
- Next: Level 5: Process Relationships: Links, Monitors, Exit Signals and Failure Propagation.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does Erlang Level 4: Processes cover?
Lightweight Processes, Message Passing, Mailboxes and Receive: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 3: Data & Pattern Matching, which covers Tuples, Maps and Records, Guards, Advanced Pattern Matching.