Sha256: 48fec3e8cf6daefbe456a90c96816d25a9f0210cc170575407608a7bc2db6bbc

Contents?: true

Size: 687 Bytes

Versions: 3

Compression:

Stored size: 687 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

3 entries across 3 versions & 1 rubygems

Version Path
celluloid-0.17.4 lib/celluloid/proxy/block.rb
celluloid-0.18.0.pre lib/celluloid/proxy/block.rb
celluloid-0.17.3 lib/celluloid/proxy/block.rb