Sha256: fef18188059b8c24c018f4ab501ffbdf83fed9e3dd8453c8f199037b02fa0c55
Contents?: true
Size: 567 Bytes
Versions: 1
Compression:
Stored size: 567 Bytes
Contents
class WaitingQueue<Queue def initialize(*args) super @mutex=Mutex.new @waitThreads=[] end def push(value) @mutex.synchronize { super } @waitThreads.each{|th|th.wakeup} @waitThreads.uniq! end def <<(value) push(value) end def pop @waitThreads<<Thread.current loop do Thread.stop if empty? @mutex.synchronize { unless empty? value=super @waitThreads.delete(self) @waitThreads.uniq! return value end } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
appswarm-0.0.1 | lib/appswarm/tools/waiting_queue.rb |