Sha256: 629c2ee766cd18b8b2884846ba78fd9a90112c1c38be28dbf520fb833237877a

Contents?: true

Size: 872 Bytes

Versions: 1

Compression:

Stored size: 872 Bytes

Contents

module Celluloid
  module Proxy
    # A proxy which creates future calls to an actor
    class Future < Abstract
      attr_reader :mailbox

      # Used for reflecting on proxy objects themselves
      def __class__
        Proxy::Future
      end

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

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

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

        if block_given?
          # FIXME: nicer exception
          fail "Cannot use blocks with futures yet"
        end

        future = ::Celluloid::Future.new
        call = Call::Sync.new(future, meth, args, block)

        @mailbox << call

        future
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
celluloid-0.17.0 lib/celluloid/proxy/future.rb