Created
March 15, 2013 00:59
-
-
Save jacobo/5166690 to your computer and use it in GitHub Desktop.
confused by sleep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'celluloid' | |
| class DiCaprio | |
| include Celluloid | |
| def do_a_thing | |
| puts "starting" | |
| `sleep 1` | |
| puts "finished" | |
| end | |
| end | |
| class Deniro | |
| include Celluloid | |
| def do_something | |
| puts "starting" | |
| sleep 1 | |
| puts "finished" | |
| end | |
| end | |
| leo = DiCaprio.new | |
| 5.times{ leo.async.do_a_thing } | |
| robert = Deniro.new | |
| 5.times{ robert.async.do_something } | |
| Thread.stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See: https://github.com/celluloid/celluloid/wiki/Pipelining-and-execution-modes
Two alternatives which will have the same behavior as the backtic'd
sleep 1or