Class: Queue

Inherits:
Object
  • Object
show all
Defined in:
lib/cinch/rubyext/queue.rb

Instance Method Summary collapse

Instance Method Details

#unshift(obj) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cinch/rubyext/queue.rb', line 3

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