Skip to content

Instantly share code, notes, and snippets.

@jacobo
Created March 15, 2013 00:59
Show Gist options
  • Select an option

  • Save jacobo/5166690 to your computer and use it in GitHub Desktop.

Select an option

Save jacobo/5166690 to your computer and use it in GitHub Desktop.
confused by sleep
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
@tarcieri
Copy link

See: https://github.com/celluloid/celluloid/wiki/Pipelining-and-execution-modes

Two alternatives which will have the same behavior as the backtic'd sleep 1

Kernel.sleep 1

or

exclusive { sleep 1 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment