Search⌘ K
AI Features

Tasks

Explore how to use Elixir Tasks to run functions in the background and manage state with Agents. Learn to leverage these abstractions to simplify process handling while benefiting from OTP's robustness. This lesson helps you understand task supervision options and practical coding examples for concurrent programming.

We'll cover the following...

This part of the course is about processes and process distribution. So far, we’ve covered two extremes. In the initial chapters, we looked at the spawn primitive, along with message sending and receiving and multimode operations. Later, we looked at OTP, the juggernaut of process architecture.

Sometimes, though, we want something in the middle. We want to be able to run simple processes, either for background processing or for maintaining state. But we don’t want to be bothered with the low-level details of spawn, send, and receive, and we really don’t need the extra control that writing our own GenServer gives us.

Enter tasks and agents, which are two simple-to-use Elixir abstractions. These use OTP’s features but insulate us from these details.

Tasks

...