Class: Queue

Inherits:
Object
  • Object
show all
Defined in:
lib/newton/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/newton/rubyext/queue.rb', line 3

def unshift(obj)
  Thread.critical = true
  @que.unshift obj
  begin
    t = @waiting.shift
    t.wakeup if t
  rescue ThreadError
    retry
  ensure
    Thread.critical = false
  end
  begin
    t.run if t
  rescue ThreadError
  end
end