class Async::Queue(T)
- Async::Queue(T)
- Reference
- Object
Overview
First in, first out (FIFO) queue based on Python's own asyncio.Queue
.
Included Modules
- Enumerable(T)
Defined in:
async/queue.crConstructors
-
.new(max_size : Int32 | Nil = nil)
Initializes a new
Queue
.
Instance Method Summary
-
#each(&block : T -> )
Iterate over each item in the queue.
-
#empty?
Returns true if the queue is empty.
-
#full?
Returns true if there are
#max_size
items in the queue. -
#get
Remove and return an item from the queue.
-
#get!
Return an item if one is immediately available, else raise
QueueEmptyError
. -
#get_sync
Remove and return an item from the queue.
-
#max_size : Int32 | Nil
Returns the set max size for the queue.
-
#push!(item : T)
Put an item into the queue without blocking.
-
#put(item : T)
Put an item into the queue.
- #put_sync(item : T)
-
#size
Returns the number of items in the queue.
Constructor Detail
Initializes a new Queue
.
If #max_size
is less than or equal to zero, the queue size is infinite.
If it is an integer greater than 0, then await #put
blocks when the queue
reaches #max_size
until an item is removed by #get
.
Instance Method Detail
Remove and return an item from the queue. If the queue is empty, wait until an item is available.
Remove and return an item from the queue. If the queue is empty, wait until an item is available.
Put an item into the queue without blocking. If no free slot is
immediately available, raise QueueFullError
.
Put an item into the queue. If the queue is full, wait until a free slot is available before adding the item.