class LimitedQueue
A thread-safe queue which limits the number of items that can be enqueued.
Signature
- public
Since Async v1.
Definitions
def self.new(...)
- private
Signature
- private
This exists purely for emitting a warning.
Implementation
def self.new(...)
warn("`require 'async/limited_queue'` to use `Async::LimitedQueue`.", uplevel: 1, category: :deprecated) if $VERBOSE
super
end
def initialize(limit = 1, **options)
Create a new limited queue.
Signature
-
parameterã
limit
ãInteger
The maximum number of items that can be enqueued.
-
parameterã
full
ãNotification
The notification to use for signaling when the queue is full. (ignored, for compatibility)
Implementation
def initialize(limit = 1, **options)
super(**options, delegate: Thread::SizedQueue.new(limit))
end
def limit
Signature
-
attributeã
Integer
The maximum number of items that can be enqueued.
Implementation
def limit
@delegate.max
end
def limited?
Signature
-
returnsã
Boolean
Whether trying to enqueue an item would block.
Implementation
def limited?
!@delegate.closed? && @delegate.size >= @delegate.max
end