Sha256: b005ad33b505b613e9b9f1d5cfdad3232999e61d9ba7334ecc9b134896698fa9

Contents?: true

Size: 686 Bytes

Versions: 2

Compression:

Stored size: 686 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
          raise "No task to suspend"
        end
      end
    else
      @block
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
celluloid-0.18.0 lib/celluloid/proxy/block.rb
celluloid-0.18.0.pre2 lib/celluloid/proxy/block.rb