class Backports::Ractor::OutgoingQueue

  • Add ‘ack: ` to push (blocking)
    * Wraps exception

def close(how = :hard)

def close(how = :hard)
  super()
  return if how == :soft
  clear
  @ack_queue.close
end

def initialize

def initialize
  @ack_queue = ::Queue.new
  super
end

def pop(timeout: nil, ack: true)

def pop(timeout: nil, ack: true)
  r = super(timeout: timeout)
  @ack_queue << :done if ack
  raise r.exception if WrappedException === r
  r
end

def push(obj, ack:)

def push(obj, ack:)
  super(obj)
  if ack
    r = @ack_queue.pop # block until popped
    raise ClosedError, "The #{self.class::TYPE}-port is already closed" unless r == :done
  end
  self
end