Sha256: 6db8528003ce334609af3a0ee2cf29b23a30aa93c5f6fdb29fc344d4ebb8763e

Contents?: true

Size: 684 Bytes

Versions: 4

Compression:

Stored size: 684 Bytes

Contents

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
celluloid-0.17.2 lib/celluloid/proxy/block.rb
celluloid-0.17.1.2 lib/celluloid/proxy/block.rb
celluloid-0.17.1.1 lib/celluloid/proxy/block.rb
celluloid-0.17.1 lib/celluloid/proxy/block.rb