class Sequence::Queue

Public Instance Methods

peek(non_block=false) click to toggle source

Retrieves next data from the queue, without pulling it off the queue. If the queue is empty, the calling thread is suspended until data is pushed onto the queue. If non_block is true, the thread isn't suspended, and an exception is raised.

# File lib/sequence/enum.rb, line 120
def peek(non_block=false)
  raise ThreadError, "queue empty" if non_block and empty?
  Thread.pass while (empty?)
  Thread.critical=true
    result=@que.first
  Thread.critical=false
  result
end
read(len) click to toggle source
# File lib/sequence/enum.rb, line 129
def read(len)
  Thread.critical=true
    result=@que.slice![0...len]
  Thread.critical=false
  result
end