class Async::Queue(T)

Overview

First in, first out (FIFO) queue based on Python's own asyncio.Queue.

Included Modules

Defined in:

async/queue.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(max_size : Int32 | Nil = nil) #

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.


[View source]

Instance Method Detail

def each(&block : T -> ) #

Iterate over each item in the queue. See Array#each.


[View source]
def empty? #

Returns true if the queue is empty.


[View source]
def full? #

Returns true if there are #max_size items in the queue.


[View source]
def get #

Remove and return an item from the queue. If the queue is empty, wait until an item is available.


[View source]
def get! #

Return an item if one is immediately available, else raise QueueEmptyError.


[View source]
def get_sync #

Remove and return an item from the queue. If the queue is empty, wait until an item is available.


[View source]
def max_size : Int32 | Nil #

Returns the set max size for the queue.


[View source]
def push!(item : T) #

Put an item into the queue without blocking. If no free slot is immediately available, raise QueueFullError.


[View source]
def put(item : T) #

Put an item into the queue. If the queue is full, wait until a free slot is available before adding the item.


[View source]
def put_sync(item : T) #

[View source]
def size #

Returns the number of items in the queue.


[View source]