How the Go language can be used to implement a version of the Actor Model for concurrent programming.
Talk given at the Golang UK conference, August 2016
Video: https://www.youtube.com/watch?v=yCbon_9yGVs
3. According to Wikipedia…
The actor model in computer science is a
mathematical model of concurrent computation that
treats "actors" as the universal primitives of
concurrent computation.
4. Actors’ Advocacy
• Good for highly concurrent systems
• Easier to write
• Easier to reason about
19. Non-blocking send
func (actor *SomeActor) TryTo(something) {
select {
case actor.actionChan <- func() {
// do the thing
}:
default:
// chan is full; throw it away
}
}
20. Back to the theory
• An actor can designate the behaviour to be used for the
next message it receives.
• Messages are sent to actors at addresses
• Compare CSP: processes are anonymous and
channels are named
• We use a pointer to the actor as its address
• Unbounded nondeterminism
21. In Practice
Pro:
• No lock/unlock
• Simple model
• Identifies goroutines
Con:
• Debugging/testing
• Single reader/writer
• No framework!
24. Summary
• “Do not communicate by sharing memory; instead, share
memory by communicating” - Effective Go
• Go provides the components to work in an actor style
• No framework - just type in a few lines
• Departs from Actor theory in a few ways
• In use in production for two years
- http://github.com/weaveworks/mesh