SlideShare a Scribd company logo
1 of 41
Download to read offline
Ruby
                     goes to

                        @elise_huard Euruko 2011
Monday 30 May 2011
Why Concurrency?



Monday 30 May 2011
“... 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)




Monday 30 May 2011
Concurrency !=
                       Parallellism


Monday 30 May 2011
3 threads, 2 cores


                      1                    1       2




                      2                    3
                                                   1




                       3                   3
                                                   2




                       1




                     core1   core2         core1   core2


Monday 30 May 2011
Your program




                                language VM



                                     OS
                     (kernel processes, other processes)


                          multicore - multiCPU


Monday 30 May 2011
Concurrency will melt
                    your brain

                     non-determinism
                     mutable AND shared state



Monday 30 May 2011
Actor Model




Monday 30 May 2011
Hewitt et al. 1973
                     no shared state
                     in response to a message, an actor can:
                     make local decisions
                     create more actors
                     send more messages
                     determine how to respond to the next message
                     received



Monday 30 May 2011
Hewitt et al. 1973


                     Generalization of the lambda
                     calculus



Monday 30 May 2011
Inspiration

                     artificial intelligence
                     ‘quantum mechanics’ - observing details
                     by which the order of arrival of
                     messages for an actor is determined
                     can affect result



Monday 30 May 2011
The point
                      only actors - no global state
                      partial order of execution




           from http://pragprog.com/titles/vspcon/programming-concurrency-on-the-jvm




Monday 30 May 2011
Implementations

                     • using threads/processes
                     • async messaging - mailbox
                     • pattern matching on incoming messages
                     • actors = state machines.

Monday 30 May 2011
Lifecycle




                     from http://pragprog.com/titles/vspcon/programming-concurrency-on-the-jvm




Monday 30 May 2011
Sleeping barber
                     shop with x chairs
                     1 barber
                         no customer: sleep. customers: cut hairs
                     customer
                         if barber is sleeping: wake him up
                         else if enough chairs take a chair
                         else leave


Monday 30 May 2011
Monday 30 May 2011
Actors in Ruby




Monday 30 May 2011
Concurrent gem

                     theoretical - different concurrency
                     models
                     https://github.com/mental/concurrent




Monday 30 May 2011
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"




Monday 30 May 2011
Revactor

               concurrent I/O for networking
               apps
               Evented rather than parallel
                     https://github.com/tarcieri/revactor



Monday 30 May 2011
Celluloid


                     thread-based actors
                     based on erlang

                      https://github.com/tarcieri/celluloid


Monday 30 May 2011
No true parallelism
                          with MRI


Monday 30 May 2011
Cheat on Ruby


Monday 30 May 2011
Erlang


                     light-weight processes
                     = actors


Monday 30 May 2011
Erlang

                     blocking receives
                     timeouts
                     supervision trees: fault-tolerance



Monday 30 May 2011
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

              https://github.com/mojombo/erlectricity
Monday 30 May 2011
Reia or Elixir


                     languages on erlang vm
                     friendlier, more ruby-like, OO



Monday 30 May 2011
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


Monday 30 May 2011
Akka



                actor model + software transactional memory
                               java and scala



Monday 30 May 2011
Akka

                     • sending: reply is possible or not, sync or
                       async
                     • supervision: several strategies
                     • as library or as framework
                     • local and distributed

Monday 30 May 2011
JRuby!



Monday 30 May 2011
Caveat



Monday 30 May 2011
Advantages

                     easy to grasp
                     real encapsulation -
                     separation of concerns
                     highly decentralized

Monday 30 May 2011
But


                     many messages (bandwidth)
                     livelocks are still possible



Monday 30 May 2011
Back to Ruby




Monday 30 May 2011
Time to control
                         shared state ?
                     Change RubySpec:
                     default: variables not shared between
                     threads?
                     integrate better concurrency primitives
                     into the Ruby stdlib ?


Monday 30 May 2011
Let’s think about it.



Monday 30 May 2011
Thanks
                             @elise_huard




                     http://www.delicious.com/elisehuard/concurrency
Monday 30 May 2011
Ruby
                      goes to
                     Hollywood
                           Elise Huard LRUG 11-04-2011
Monday 30 May 2011
Ruby
                      goes to
                     Hollywood
                            Elise Huard LRUG
Monday 30 May 2011
Monday 30 May 2011

More Related Content

Similar to Ruby goes to hollywood

web标准化交流会上海站bobby分享
web标准化交流会上海站bobby分享web标准化交流会上海站bobby分享
web标准化交流会上海站bobby分享裕波 周
 
web标准化交流会bobby分享
web标准化交流会bobby分享web标准化交流会bobby分享
web标准化交流会bobby分享裕波 周
 
Erlang: Bult for concurrent, distributed systems
Erlang: Bult for concurrent, distributed systemsErlang: Bult for concurrent, distributed systems
Erlang: Bult for concurrent, distributed systemsKen Pratt
 
Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.Peter Neubauer
 
Our Best Practices Are Killing Us
Our Best Practices Are Killing UsOur Best Practices Are Killing Us
Our Best Practices Are Killing UsNicole Sullivan
 
NodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time WebNodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time WebJakub Nesetril
 
Scaling websites with RabbitMQ A(rlvaro Videla)
Scaling websites with RabbitMQ   A(rlvaro Videla)Scaling websites with RabbitMQ   A(rlvaro Videla)
Scaling websites with RabbitMQ A(rlvaro Videla)Ontico
 
Stackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content ManagementStackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content ManagementVance Lucas
 
BDD For Zend Framework With PHPSpec
BDD For Zend Framework With PHPSpecBDD For Zend Framework With PHPSpec
BDD For Zend Framework With PHPSpecMarcello Duarte
 
Building an alarm clock with node.js
Building an alarm clock with node.jsBuilding an alarm clock with node.js
Building an alarm clock with node.jsFelix Geisendörfer
 

Similar to Ruby goes to hollywood (11)

web标准化交流会上海站bobby分享
web标准化交流会上海站bobby分享web标准化交流会上海站bobby分享
web标准化交流会上海站bobby分享
 
web标准化交流会bobby分享
web标准化交流会bobby分享web标准化交流会bobby分享
web标准化交流会bobby分享
 
Erlang: Bult for concurrent, distributed systems
Erlang: Bult for concurrent, distributed systemsErlang: Bult for concurrent, distributed systems
Erlang: Bult for concurrent, distributed systems
 
Dev-Time Liferay
Dev-Time  LiferayDev-Time  Liferay
Dev-Time Liferay
 
Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.
 
Our Best Practices Are Killing Us
Our Best Practices Are Killing UsOur Best Practices Are Killing Us
Our Best Practices Are Killing Us
 
NodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time WebNodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time Web
 
Scaling websites with RabbitMQ A(rlvaro Videla)
Scaling websites with RabbitMQ   A(rlvaro Videla)Scaling websites with RabbitMQ   A(rlvaro Videla)
Scaling websites with RabbitMQ A(rlvaro Videla)
 
Stackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content ManagementStackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content Management
 
BDD For Zend Framework With PHPSpec
BDD For Zend Framework With PHPSpecBDD For Zend Framework With PHPSpec
BDD For Zend Framework With PHPSpec
 
Building an alarm clock with node.js
Building an alarm clock with node.jsBuilding an alarm clock with node.js
Building an alarm clock with node.js
 

More from ehuard

Euroclojure 2017
Euroclojure 2017Euroclojure 2017
Euroclojure 2017ehuard
 
Ruby goes to Hollywood
Ruby goes to HollywoodRuby goes to Hollywood
Ruby goes to Hollywoodehuard
 
Ruby hollywood nordic
Ruby hollywood nordicRuby hollywood nordic
Ruby hollywood nordicehuard
 
Concurrency: Rubies, plural
Concurrency: Rubies, pluralConcurrency: Rubies, plural
Concurrency: Rubies, pluralehuard
 
Concurrency
ConcurrencyConcurrency
Concurrencyehuard
 
Concurrency
ConcurrencyConcurrency
Concurrencyehuard
 
12 hours to rate a rails application
12 hours to rate a rails application12 hours to rate a rails application
12 hours to rate a rails applicationehuard
 
how to rate a Rails application
how to rate a Rails applicationhow to rate a Rails application
how to rate a Rails applicationehuard
 
12 Hours To Rate A Rails Application
12 Hours To Rate A Rails Application12 Hours To Rate A Rails Application
12 Hours To Rate A Rails Applicationehuard
 
Barcamp Ghent2009
Barcamp Ghent2009Barcamp Ghent2009
Barcamp Ghent2009ehuard
 
Tokyo Cabinet
Tokyo CabinetTokyo Cabinet
Tokyo Cabinetehuard
 
The real-time web
The real-time webThe real-time web
The real-time webehuard
 
Rails and the internet of things
Rails and the internet of thingsRails and the internet of things
Rails and the internet of thingsehuard
 

More from ehuard (14)

Euroclojure 2017
Euroclojure 2017Euroclojure 2017
Euroclojure 2017
 
Ruby goes to Hollywood
Ruby goes to HollywoodRuby goes to Hollywood
Ruby goes to Hollywood
 
Ruby hollywood nordic
Ruby hollywood nordicRuby hollywood nordic
Ruby hollywood nordic
 
Concurrency: Rubies, plural
Concurrency: Rubies, pluralConcurrency: Rubies, plural
Concurrency: Rubies, plural
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
12 hours to rate a rails application
12 hours to rate a rails application12 hours to rate a rails application
12 hours to rate a rails application
 
how to rate a Rails application
how to rate a Rails applicationhow to rate a Rails application
how to rate a Rails application
 
12 Hours To Rate A Rails Application
12 Hours To Rate A Rails Application12 Hours To Rate A Rails Application
12 Hours To Rate A Rails Application
 
Barcamp Ghent2009
Barcamp Ghent2009Barcamp Ghent2009
Barcamp Ghent2009
 
Tokyo Cabinet
Tokyo CabinetTokyo Cabinet
Tokyo Cabinet
 
The real-time web
The real-time webThe real-time web
The real-time web
 
Rails and the internet of things
Rails and the internet of thingsRails and the internet of things
Rails and the internet of things
 
Oauth
OauthOauth
Oauth
 

Recently uploaded

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

Ruby goes to hollywood

  • 1. Ruby goes to @elise_huard Euruko 2011 Monday 30 May 2011
  • 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) Monday 30 May 2011
  • 4. Concurrency != Parallellism Monday 30 May 2011
  • 5. 3 threads, 2 cores 1 1 2 2 3 1 3 3 2 1 core1 core2 core1 core2 Monday 30 May 2011
  • 6. Your program language VM OS (kernel processes, other processes) multicore - multiCPU Monday 30 May 2011
  • 7. Concurrency will melt your brain non-determinism mutable AND shared state Monday 30 May 2011
  • 9. Hewitt et al. 1973 no shared state in response to a message, an actor can: make local decisions create more actors send more messages determine how to respond to the next message received Monday 30 May 2011
  • 10. Hewitt et al. 1973 Generalization of the lambda calculus Monday 30 May 2011
  • 11. Inspiration artificial intelligence ‘quantum mechanics’ - observing details by which the order of arrival of messages for an actor is determined can affect result Monday 30 May 2011
  • 12. The point only actors - no global state partial order of execution from http://pragprog.com/titles/vspcon/programming-concurrency-on-the-jvm Monday 30 May 2011
  • 13. Implementations • using threads/processes • async messaging - mailbox • pattern matching on incoming messages • actors = state machines. Monday 30 May 2011
  • 14. Lifecycle from http://pragprog.com/titles/vspcon/programming-concurrency-on-the-jvm Monday 30 May 2011
  • 15. Sleeping barber shop with x chairs 1 barber no customer: sleep. customers: cut hairs customer if barber is sleeping: wake him up else if enough chairs take a chair else leave Monday 30 May 2011
  • 17. Actors in Ruby Monday 30 May 2011
  • 18. Concurrent gem theoretical - different concurrency models https://github.com/mental/concurrent Monday 30 May 2011
  • 19. 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" Monday 30 May 2011
  • 20. Revactor concurrent I/O for networking apps Evented rather than parallel https://github.com/tarcieri/revactor Monday 30 May 2011
  • 21. Celluloid thread-based actors based on erlang https://github.com/tarcieri/celluloid Monday 30 May 2011
  • 22. No true parallelism with MRI Monday 30 May 2011
  • 23. Cheat on Ruby Monday 30 May 2011
  • 24. Erlang light-weight processes = actors Monday 30 May 2011
  • 25. Erlang blocking receives timeouts supervision trees: fault-tolerance Monday 30 May 2011
  • 26. 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 https://github.com/mojombo/erlectricity Monday 30 May 2011
  • 27. Reia or Elixir languages on erlang vm friendlier, more ruby-like, OO Monday 30 May 2011
  • 28. 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 Monday 30 May 2011
  • 29. Akka actor model + software transactional memory java and scala Monday 30 May 2011
  • 30. Akka • sending: reply is possible or not, sync or async • supervision: several strategies • as library or as framework • local and distributed Monday 30 May 2011
  • 33. Advantages easy to grasp real encapsulation - separation of concerns highly decentralized Monday 30 May 2011
  • 34. But many messages (bandwidth) livelocks are still possible Monday 30 May 2011
  • 35. Back to Ruby Monday 30 May 2011
  • 36. Time to control shared state ? Change RubySpec: default: variables not shared between threads? integrate better concurrency primitives into the Ruby stdlib ? Monday 30 May 2011
  • 37. Let’s think about it. Monday 30 May 2011
  • 38. Thanks @elise_huard http://www.delicious.com/elisehuard/concurrency Monday 30 May 2011
  • 39. Ruby goes to Hollywood Elise Huard LRUG 11-04-2011 Monday 30 May 2011
  • 40. Ruby goes to Hollywood Elise Huard LRUG Monday 30 May 2011