17
Actors Drammen 25.10.2012 Reidar Sollid The actor programming model

Actors drammen

Embed Size (px)

Citation preview

Page 1: Actors drammen

Actors

Drammen

25.10.2012

Reidar Sollid

The actor programming model

Page 2: Actors drammen

2 Actors - Public

Erlang

• The world is concurrent

• Things in the world don't share data

• Things communicate with messages

• Things fail

• - Joe Armstrong

Page 3: Actors drammen

3 Actors - Public

Original problem

Page 4: Actors drammen

4 Actors - Public

New problem

Page 5: Actors drammen

5 Actors - Public

Shared memory

Page 6: Actors drammen

6 Actors - Public

Shared memory model

Shared memory

Processthread

Processthread

Processthread

Page 7: Actors drammen

7 Actors - Public

Concurrency and shared memory

Page 8: Actors drammen

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

Page 9: Actors drammen

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

Page 10: Actors drammen

10 Actors - Public

Pattern matching

Page 11: Actors drammen

11 Actors - Public

Pattern matching

Page 12: Actors drammen

12 Actors - Public

Tail optimized recursion

Page 13: Actors drammen

13 Actors - Public

Tail recursion

Page 14: Actors drammen

14 Actors - Public

F# Agent

Page 15: Actors drammen

15 Actors - Public

Scala actor

Page 16: Actors drammen

16 Actors - Public

Application security

Page 17: Actors drammen

17 Actors - Public