Describe the role of schedulers.
- CPU → BEAM → Scheduler
- BEAM → List Process
- A scheduler distribute the CPU time accross the processes of the associated BEAM.
Why Elixir?
- Less code than Erlang, thanks to Lisp like macros.
How many OS processes does the BEAM use?
1
How to define structures?
To define a structure $Name
:
Given a structure definition $Name
, how to use it?
- Build an instance
i
. - Read fields of
i
. - Derive other instances from
i
. - Use it like a Map without the protocols.
- We observe that:
- Given appropriate A and B:
Enum.map : List(A) (A → B) → List(B)
Enum.map : Range(A) (A → B) → List(B)
- How does it work?
This is an instance of parametric polymorphism.
- If: an actor
act
satisfies the Enumerable protocol, - then: the
Enum
procedures are defined onact
.
All instances of List
and Range
implement the Enumerable
protocol.
Define how to build a protocol Proto
.
The procedure du build a protocol Proto
is:
- Build a new module called
Proto
using thedefprotocol
macro. - Add procedure specification to the module.
Example:
Define how to use a protocol Proto
- Using a protocol
Proto
means that a module implements its procedures. - If Elixir evaluated this code, then: the module
Mod
implements the protocolProto
.defimpl Proto, for: Mod do def area(term), do: # return the area of term, instance of Mod. end
What is an OTP compliant process?
- If: a process implements an OTP behaviour — e.g.
GenServer
orSupervisor
, - Then: it is an OTP compliant process.
- Only new ideas are recorded here.
- We use the Actor Model metaphor for a few interpretations.