class Async::Queue
A queue which allows items to be processed in order.
def <<(item)
def <<(item) @items << item self.signal unless self.empty? end
def async(parent: (@parent or Task.current), &block)
def async(parent: (@parent or Task.current), &block) while item = self.dequeue parent.async(item, &block) end end
def dequeue
def dequeue while @items.empty? self.wait end @items.shift end
def each
def each while item = self.dequeue yield item end end
def empty?
def empty? @items.empty? end
def enqueue(*items)
def enqueue(*items) @items.concat(items) self.signal unless self.empty? end
def initialize(parent: nil)
def initialize(parent: nil) super() @items = [] @parent = parent end
def size
def size @items.size end