Sha256: 76f45213c6fdfc1381c98208aadcb115a000a3d49c3ba030128e9e8ecdb947ee

Contents?: true

Size: 800 Bytes

Versions: 2

Compression:

Stored size: 800 Bytes

Contents

# A proxy which sends synchronous calls to an actor
class Celluloid::Proxy::Sync < Celluloid::Proxy::AbstractCall
  def respond_to?(meth, include_private = false)
    __class__.instance_methods.include?(meth) || method_missing(:respond_to?, meth, include_private)
  end

  def method_missing(meth, *args, &block)
    raise ::Celluloid::DeadActorError, "attempted to call a dead actor: #{meth}" unless @mailbox.alive?

    if @mailbox == ::Thread.current[:celluloid_mailbox]
      args.unshift meth
      meth = :__send__
      # actor = Thread.current[:celluloid_actor]
      # actor = actor.behavior.subject.bare_object
      # return actor.__send__(*args, &block)
    end

    call = ::Celluloid::Call::Sync.new(::Celluloid.mailbox, meth, args, block)
    @mailbox << call
    call.value
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
celluloid-0.18.0 lib/celluloid/proxy/sync.rb
celluloid-0.18.0.pre2 lib/celluloid/proxy/sync.rb