class Async::LimitedQueue
@public Since ‘stable-v1`.
def <<(item)
def <<(item) while limited? @full.wait end super end
def dequeue
def dequeue item = super @full.signal return item end
def enqueue *items
def enqueue *items while !items.empty? while limited? @full.wait end available = @limit - @items.size @items.concat(items.shift(available)) self.signal unless self.empty? end end
def initialize(limit = 1, **options)
def initialize(limit = 1, **options) super(**options) @limit = limit @full = Notification.new end
def limited?
def limited? @items.size >= @limit end