Upload
reidar-sollid
View
235
Download
3
Tags:
Embed Size (px)
Citation preview
Actors
Drammen
25.10.2012
Reidar Sollid
The actor programming model
2 Actors - Public
Erlang
• The world is concurrent
• Things in the world don't share data
• Things communicate with messages
• Things fail
• - Joe Armstrong
3 Actors - Public
Original problem
4 Actors - Public
New problem
5 Actors - Public
Shared memory
6 Actors - Public
Shared memory model
Shared memory
Processthread
Processthread
Processthread
7 Actors - Public
Concurrency and shared memory
8 Actors - Public
What is the Actor Model
• Light weight processes/tasks/agents communicating through messaging
• Messages are buffered in a “mailbox”
• No shared state
• Isolated from other processes
• Normally event systems are inversion of control
• Adding a listener to an object
• Hard to maintain in large systems
• Humans do not share memory, we communicate through messages
9 Actors - Public
React or receive
• React is the “normal” actor, lightweight process
• Receive spins out a new Java thread
• In the paper *
• 5000 threads
• 1 200 000 actors
• React uses partial functions to send the process to the heap
• Receive runs on the stack and is heavyweight JVM threads (like Java)
• *Actors That Unify Threads and Events P. Haller, M. Odersky
10 Actors - Public
Pattern matching
11 Actors - Public
Pattern matching
12 Actors - Public
Tail optimized recursion
13 Actors - Public
Tail recursion
14 Actors - Public
F# Agent
15 Actors - Public
Scala actor
16 Actors - Public
Application security
17 Actors - Public