Skip to content

Instantly share code, notes, and snippets.

@meetme2meat
Last active September 19, 2015 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meetme2meat/e277b0efae9e2a0cdfc2 to your computer and use it in GitHub Desktop.
Save meetme2meat/e277b0efae9e2a0cdfc2 to your computer and use it in GitHub Desktop.
## Even with sleep 0 the code does not work and no message is ever printed over STDOUT.
## which is weird considering the celluloid-zmq (working.rb) example work with almost same code.
require 'celluloid'
class Server
include Celluloid
def run
loop { [1].each { |i| async.handle_message 'hello' } ; sleep(0) }
end
def handle_message(message)
puts "got message: #{message}"
end
end
server = Server.new()
server.async.run
sleep
#### OUTPUT ####
I, [2015-09-19T17:39:08.116435 #17876] INFO -- : Celluloid 0.17.1.1 is running in BACKPORTED mode. [ http://git.io/vJf3J ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment