Sha256: 4b307c833c27a4741af77a732f2cb62b2e08f78d5041b9b546db022d91d6ea80

Contents?: true

Size: 717 Bytes

Versions: 21

Compression:

Stored size: 717 Bytes

Contents

module Celluloid
  class BlockProxy
    def initialize(call, mailbox, block)
      @call = call
      @mailbox = mailbox
      @block = block
      @execution = :sender
    end
    attr_writer :execution
    attr_reader :call, :block

    def to_proc
      if @execution == :sender
        lambda do |*values|
          if task = Thread.current[:celluloid_task]
            @mailbox << BlockCall.new(self, Actor.current.mailbox, values)
            # TODO: if respond fails, the Task will never be resumed
            task.suspend(:invokeblock)
          else
            # FIXME: better exception
            raise "No task to suspend"
          end
        end
      else
        @block
      end
    end
  end
end

Version data entries

21 entries across 19 versions & 6 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/celluloid-0.16.0/lib/celluloid/proxies/block_proxy.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/celluloid-0.16.0/lib/celluloid/proxies/block_proxy.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/proxies/block_proxy.rb
scoot-0.0.4 .bundle/gems/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/proxies/block_proxy.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/celluloid-0.16.0/lib/celluloid/proxies/block_proxy.rb
celluloid-0.16.0 lib/celluloid/proxies/block_proxy.rb
celluloid-0.16.0.pre3 lib/celluloid/proxies/block_proxy.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/celluloid-0.15.2/lib/celluloid/proxies/block_proxy.rb
celluloid-0.16.0.pre2 lib/celluloid/proxies/block_proxy.rb
celluloid-0.16.0.pre lib/celluloid/proxies/block_proxy.rb
celluloid-0.15.2 lib/celluloid/proxies/block_proxy.rb
celluloid-0.15.1 lib/celluloid/proxies/block_proxy.rb
celluloid-0.15.0 lib/celluloid/proxies/block_proxy.rb
celluloid-0.15.0.pre2 lib/celluloid/proxies/block_proxy.rb
celluloid-0.15.0.pre lib/celluloid/proxies/block_proxy.rb
celluloid-0.14.1 lib/celluloid/proxies/block_proxy.rb
celluloid-0.14.1.pre lib/celluloid/proxies/block_proxy.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/celluloid-0.14.0/lib/celluloid/proxies/block_proxy.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/celluloid-0.14.0/lib/celluloid/proxies/block_proxy.rb
celluloid-0.14.0 lib/celluloid/proxies/block_proxy.rb