Module: Green::EM
Instance Method Summary collapse
Instance Method Details
#get_args(args, proc_args) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/green-em.rb', line 12 def get_args(args, proc_args) case proc_args when Proc proc.call(*args) when nil args else proc_args end end |
#sync(deferrable, params = {}) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/green-em.rb', line 5 def sync(deferrable, params = {}) g = Green.current deferrable.callback { |*args| g.switch(*get_args(args, params[:errback_args])) } deferrable.errback { |*args| g.throw(get_args(args, params[:errback_args]).first) } Green.hub.wait { deferrable.green_cancel } end |