3. “... for the first time in history, no one is
building a much faster sequential processor.
If you want your programs to run
significantly faster (...) you’re going to have to
parallelize your program.”
Hennessy and Patterson
“Computer Architectures” (4th edition, 2007)
Tuesday 12 April 2011
9. Hewitt et al. 1973
no shared state
in response to a message that it
receives, an actor can:
make local decisions
create more actors
send more messages
determine how to respond to the next message
received
Tuesday 12 April 2011
10. Inspiration
Artificial Intelligence
quantum mechanics - we cannot
observe the details by which the order
of arrival of messages for an actor is
determined. attempting to do so can
affect result and push indeterminacy
elsewhere.
Tuesday 12 April 2011
11. The point
only actors
no global state
partial order of execution
Tuesday 12 April 2011
14. Rubinius Actors
require 'actor'
actor = Actor.spawn(Actor.current) do |master|
msg = Actor.receive
master.send msg
end
actor.send "test"
msg = Actor.receive
# msg == "test"
Tuesday 12 April 2011
15. Revactor
sock = Revactor::TCP.connect(host, port)
listener = Revactor::TCP.listen(addr, port)
sock = listener.accept
sock.controller = Actor.current
sock.active = true
Actor.receive do |filter|
filter.when(Case[:tcp, sock, Object]) do |_, _, data|
...
end
filter.when(Case[:somethingelse, Object]) do |_,
message|
...
end
end
Tuesday 12 April 2011
16. Concurrent gem
theoretical - different concurrency
models
use rubinius style actors in other
versions of Ruby
https://github.com/mental/concurrent
Tuesday 12 April 2011
19. Erlang
light-weight processes
= actors
Tuesday 12 April 2011
20. Erlectricity
https://github.com/mojombo/erlectricity
require 'rubygems'
require 'erlectricity'
receive do |f|
f.when([:echo, String]) do |text|
f.send!([:result, "You said: #{text}"])
f.receive_loop
end
end
Tuesday 12 April 2011
22. BERT RPC
BERT (Binary ERlang Term) serialization library
for Ruby.
convert data into erlang binary format before
sending them over the wire
Tuesday 12 April 2011
23. Scala
“We also included enhancements to make it
easier to call from Ruby into Scala libraries,
which has enabled the Lift web framework to
offer support for Ruby.” Charles Nutter, ‘JRuby 1.6 released,
now what ?’
http://www.engineyard.com/blog/2011/jruby-1-6-released-now-what/
Actors in standard library
Tuesday 12 April 2011
24. Akka
https://github.com/danielribeiro/RubyOnAkka
Tuesday 12 April 2011
26. Time to control
shared state ?
Change RubySpec ?
default variables: not shared between
threads
have keyword for shared variables
Tuesday 12 April 2011