class Async::Queue

A queue which allows items to be processed in order.

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(item)

def enqueue(item)
	@items.push(item)
	
	self.signal unless self.empty?
end

def initialize(parent: nil)

def initialize(parent: nil)
	super()
	
	@items = []
	@parent = parent
end