Skip to main content
Module

x/workerio/deps.ts>Queue

🦕 Deno module to translate Worker's system of messages into Reader and Writer
Go to Latest
class Queue
import { Queue } from "https://deno.land/x/workerio@v2.0.0/deps.ts";

A first in, first out (FIFO) queue. Non thread-safe.

If maxsize 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 maxsize until an item is removed by get().

Not like Python asyncio's Queue, join()/task_done() methods are not implemented.

Constructors

new
Queue(maxsize?)

Methods

empty(): boolean

Return true if the queue is empty, false otherwise.

full(): boolean

Return true if there are maxsize items in the queue. If the queue was initialized with maxsize=0 (the default), then full() never returns true.

get(): Promise<T>

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

Return an item if one is immediately available, else throw a QueueEmpty error.

put(value: T): Promise<void>

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

put_nowait(value: T): void

Put an item into the queue without blocking. If no free slot is immediately available, throw a QueueFull error.

qsize(): number

Return the number of items in the queue.