5. PROCESSES
OVERVIEW
▸ Not a server process or thread
▸ A process in the Erlang VM (BEAM)
▸ Lightweight
▸ Utilizes all cores
ELIXIR PROCESSES
6. ELIXIR PROCESSES
▸send and receive messages
▸unique process id
▸message mailbox
▸execute asynchronously
▸isolated - no shared memory
▸hold state
ELIXIR PROCESSES
9. ELIXIR PROCESSES VS
RUBY OBJECTS
▸ #spawn #new
▸ process id instance
▸ #send/#receive .
▸ has state has state
▸ isolated memory shared memory
▸ asynchronous synchronous
12. ELIXIR PROCESSES
LINKING PROCESSES
▸Link processes with #spawn_link
▸Linking creates a parent-child relationship
▸Child exits by default cause the parent to exit
▸Exits can be “trapped” by a parent
▸Trapped exits let parents make a decision
14. ELIXIR PROCESSES
WHAT HAVE WE GAINED?
▸More throughput
▸Easy, parallel computations
▸Avoidance of key concurrency problems
▸Failure control
15. ELIXIR PROCESSES
OTP IS NEXT
▸ "Open Telecom Platform" is an
outdated name
▸ Let's just call it OTP
▸ A set of tools and abstractions to
manage BEAM processes
16. ‣ User story solution: https://github.com/adsteel/metex
‣ Live coding examples: https://gist.github.com/adsteel/3fb26673edc6892583c9fed588452d25
‣ Elixir Process Ping Pong - http://eddwardo.github.io/elixir/2015/10/22/elixir-pingpong-table/
‣ Trapping exits - http://www.akitaonrails.com/2015/11/22/observing-processes-in-elixir-the-little-elixir-otp-
guidebook
‣ The Little Elixir and OTP Guidebook, by Benjamin Tan Wei Hao
‣ The Actor Model - https://www.youtube.com/watch?v=7erJ1DV_Tlo
Additional Resources