Tasks
- Task.async. Task.async runs a function concurrently: await joining the result with a timeout.
- Task.async_stream. async_stream maps a collection concurrently with bounded workers: fan-out with backpressure built in.
- Supervised tasks. Production tasks start under a Task.Supervisor: crashes contained, shutdown clean.
Agents
- Agents. An Agent wraps state in a process: get and update through simple functions.
- When agents fit. Agents suit simple shared state: counters, caches: anything smarter deserves a GenServer.
- Bottleneck awareness. One agent serialises access: a hot agent is a bottleneck measured, then redesigned.
Managing Concurrent Work
- Fan-out patterns. Fan out with tasks, join with await: partial failures handled per task, not ignored.
- Timeout discipline. Every await carries a timeout: and a decision about what its expiry means.
- Ownership of results. Concurrent design names one owner per piece of state: everyone else asks politely.
Before and after this level
- Before: Level 5: Processes: Processes, Messages, Links and Monitors.
- Next: Level 7: GenServer: Stateful Processes, Calls and Casts, Designing Reliable Servers.
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 Elixir Level 6: Tasks & Agents cover?
Tasks, Agents, Managing Concurrent Work: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 5: Processes, which covers Processes, Messages, Links and Monitors.