This document discusses parallel programming in Elixir. It explains that Elixir uses lightweight processes to enable concurrency and communication between processes uses message passing. It describes key Elixir mechanisms including processes, spawning processes, process identifiers (PIDs), OTP, GenServers, Supervisors, and Applications. It provides examples of how to use GenServers and Supervisors and defines what an Elixir Application is. Finally, it introduces the Exstreme library for building and running computational graphs in Elixir.
4. PROCESSES
Processes are the fundamental unit of concurrency in Elixir
The Erlang VM supports up to 134 million of processes
Lightweight processes
Each actor is a process
Each process performs a speci鍖c task
Sends messages to communicate with the process
The processes dont share information
6. PID
Identi鍖es a process in the EVM
To send a message must point the pid
7. OTP
The Erlang interpreter and compiler
Erlang standard libraries
Dialyzer, a static analysis tool
Mnesia, a distributed database
Erlang Term Storage (ETS), an in-memory database
A debugger,
An event tracer
A release management tool
8. OTP BEHAVIOURS
GenServer A behaviour module for implementing the
server of a client-server relation.
Supervisor A behaviour module for implementing
supervision functionality
Application A module for working with applications and
de鍖ning application callbacks.
9. GEN SERVER - MODULE CALLS
GenServer.start_link/3
GenServer.call/3
GenServer.cast/2
10. GEN SERVER - CALLBACKS
init(args)
handle_call(msg, {from, ref}, state}
handle_cast(msg, state}
handle_info(msg, state)
terminate(reason, state)
code_change(old_vsn, state, extra)
19. APPLICATION
Component implementing some speci鍖c functionality, that
can be started and stopped as a unit, and which can be re-
used in other systems
De鍖nes a supervision tree that must be started and
stopped when the application starts and stops
The start callback should return {:ok, pid}