Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'eventmachine'
- class Actor
- def initialize(&cb)
- @channel = EM::Channel.new
- @sid = @channel.subscribe &cb
- end
- def << message
- @channel.push message
- end
- def die
- @channel.unsubscribe(@sid)
- end
- end
- EM::run {
- actor = Actor.new { |message| puts message }
- actor << "woot"
- EM::stop_event_loop
- }
Add Comment
Please, Sign In to add comment