Sha256: ccb0c6f391fbcb171a0fa6ad8444cabe25402f4762ce03d7b3bc3a7bc6e4b946

Contents?: true

Size: 880 Bytes

Versions: 6

Compression:

Stored size: 880 Bytes

Contents

module Celluloid
  # A proxy which sends synchronous calls to an actor
  class SyncProxy < AbstractProxy
    attr_reader :mailbox

    # Used for reflecting on proxy objects themselves
    def __class__; SyncProxy; end

    def initialize(mailbox, klass)
      @mailbox, @klass = mailbox, klass
    end

    def inspect
      "#<Celluloid::SyncProxy(#{@klass})>"
    end

    def respond_to?(meth, include_private = false)
      __class__.instance_methods.include?(meth) || super
    end

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

      if @mailbox == ::Thread.current[:celluloid_mailbox]
        args.unshift meth
        meth = :__send__
      end

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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/celluloid-0.15.2/lib/celluloid/proxies/sync_proxy.rb
celluloid-0.15.2 lib/celluloid/proxies/sync_proxy.rb
celluloid-0.15.1 lib/celluloid/proxies/sync_proxy.rb
celluloid-0.15.0 lib/celluloid/proxies/sync_proxy.rb
celluloid-0.15.0.pre2 lib/celluloid/proxies/sync_proxy.rb
celluloid-0.15.0.pre lib/celluloid/proxies/sync_proxy.rb