Sha256: e47b906429b8c7fa45a1ce83885dd05f1a37f1958a25a363e0c6bcca762f722a
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
Contents
module Celluloid class ActorProxy # method_missing black magic to call bang predicate methods asynchronously def method_missing(meth, *args, &block) # bang methods are async calls if meth.match(/!$/) Logger.deprecate("'bang method'-style async syntax is deprecated and will be removed in Celluloid 1.0." + "Call async methods with 'actor.async.method'.") unbanged_meth = meth.to_s unbanged_meth.slice!(-1, 1) Actor.async @mailbox, unbanged_meth, *args, &block else Actor.call @mailbox, meth, *args, &block end end end module InstanceMethods # Process async calls via method_missing def method_missing(meth, *args, &block) # bang methods are async calls if meth.to_s.match(/!$/) Logger.deprecate("'bang method'-style async syntax is deprecated and will be removed in Celluloid 1.0." + "Call async methods with 'actor.async.method'.") unbanged_meth = meth.to_s.sub(/!$/, '') args.unshift unbanged_meth call = AsyncCall.new(:__send__, args, block) begin Thread.current[:celluloid_actor].mailbox << call rescue MailboxError # Silently swallow asynchronous calls to dead actors. There's no way # to reliably generate DeadActorErrors for async calls, so users of # async calls should find other ways to deal with actors dying # during an async call (i.e. linking/supervisors) end return end super end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
celluloid-0.13.0 | lib/celluloid/legacy.rb |
celluloid-0.13.0.pre2 | lib/celluloid/legacy.rb |
celluloid-0.13.0.pre | lib/celluloid/legacy.rb |