class OpenEndedQueue

Like Ruby's Queue class, but allowing both pushing and unshifting objects.

@api private

Public Instance Methods

unshift(obj) click to toggle source

@param [Object] obj @return [void]

# File lib/cinch/open_ended_queue.rb, line 10
def unshift(obj)
  t = nil
  @mutex.synchronize do
    @que.unshift obj
    begin
      t = @waiting.shift
      t&.wakeup
    rescue ThreadError
      retry
    end
  end
  begin
    t&.run
  rescue ThreadError
  end
end