Search⌘ K

Start Tasks and Retrieve Results

Explore how to use Elixir's Task module to start concurrent tasks and retrieve their results efficiently. Learn to simulate long-running operations and improve execution time by running tasks in parallel, enhancing your ability to manage asynchronous processes.

Simple examples

To keep our project and examples simple, we won’t send real emails. However, we still need some business logic for our experiments. We use the Process.sleep/1 function to pretend to send an email. This is usually a slow operation and can take a few seconds to complete. When called with an integer, Process.sleep/1 stops the current process for the given amount of time in milliseconds. This is very handy because we can simulate code that takes a long time to complete. We can also test various edge cases, as we’ll see later. ...