Class: OpenEndedQueue Private

Inherits:
Queue
  • Object
show all
Defined in:
lib/cinch/open_ended_queue.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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

Instance Method Summary collapse

Instance Method Details

#unshift(obj) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

  • obj (Object)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cinch/open_ended_queue.rb', line 10

def unshift(obj)
  t = nil
  @mutex.synchronize {
    @que.unshift obj
    begin
      t = @waiting.shift
      t&.wakeup
    rescue ThreadError
      retry
    end
  }
  begin
    t&.run
  rescue ThreadError
  end
end