class Async::LimitedQueue

def dequeue

def dequeue
	item = super
	
	@full.signal unless @full.empty?
	
	return item
end

def enqueue item

def enqueue item
	if limited?
		@full.wait
	end
	
	super
end

def initialize(limit = 1)

def initialize(limit = 1)
	super()
	
	@limit = limit
	@full = Async::Condition.new
end

def limited?

Returns:
  • (Boolean) - Whether trying to enqueue an item would block.
def limited?
	@items.size >= @limit
end