class Async::LimitedQueue
def dequeue
def dequeue item = super @full.enqueue(nil) unless @full.empty? return item end
def enqueue item
def enqueue item if limited? @full.dequeue end super end
def initialize(limit = 1)
def initialize(limit = 1) super() @limit = limit @full = Async::Queue.new end
def limited?
-
(Boolean)
- Whether trying to enqueue an item would block.
def limited? @items.size >= @limit end