Skip to Content
Phoenix Web Development
book

Phoenix Web Development

by Brandon Richey
April 2018
Beginner to intermediate content levelBeginner to intermediate
406 pages
9h 33m
English
Packt Publishing
Content preview from Phoenix Web Development

The model - what is a task?

Instead of directly calling the spawn and spawn_link functions, we have another option available to us as a part of the standard Elixir BEAM functions. We can instead use the functionality around calling tasks for our one-off processes instead of trying to call kernel-level functions to spawn things asynchronously. The task module in Elixir provides a couple of handy functions (and we'll dive into some of this functionality in greater detail when we start talking about supervisors as well), but we'll primarily be concerned with Task.async/1, Task.async/3, and Task.await/1.

Task.async/1 is very simple; it just takes in the function that you want it to run and executes it as if it were being executed via spawn. Let's ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Phoenix in Action

Phoenix in Action

Geoffrey Lessel
Real-Time Phoenix

Real-Time Phoenix

Stephen Bussey

Publisher Resources

ISBN: 9781787284197Supplemental Content