Manuscript Documentation
v0.1.0

@std/queues.ms#

Import each required symbol with import Name from "@std/queues.ms".

BlockingQueue Native type#

A FIFO queue that waits instead of failing: put blocks while a bounded queue is full, and take blocks while the queue is empty. It synchronizes itself, so tasks share it directly. Waiting stops at cancellation, so a TaskGroup close unblocks every waiting task.

Manuscript
type BlockingQueue[T]:
    capacity: Optional[Int] = none
    fn put(value: T) -> Bool:
    fn take() -> Optional[T]:
    fn close() -> Unit:
    fn length() -> Int:
    fn is_closed() -> Bool:

BlockingQueue.capacity#

Constructor capacity in items; omission/none is unbounded, and supplied values must be positive.

Manuscript
capacity: Optional[Int] = none

BlockingQueue.close#

Closes the queue and wakes every waiting task. Queued values can still be taken; later puts return false.

Manuscript
fn close() -> Unit:

BlockingQueue.is_closed#

Reports whether close has been called.

Manuscript
fn is_closed() -> Bool:

BlockingQueue.length#

Returns the number of values currently waiting in the queue.

Manuscript
fn length() -> Int:

BlockingQueue.put#

Waits for free space, then adds the value and returns true. Returns false when the queue is closed.

Manuscript
fn put(value: T) -> Bool:

BlockingQueue.take#

Waits for a value and removes the oldest. Returns none once the queue is closed and empty.

Manuscript
fn take() -> Optional[T]:

PriorityQueue Native type#

Negative compare results put left before right; equal priorities remain FIFO.

Manuscript
type PriorityQueue[T]:
    compare: fn(left: T, right: T) -> Int
    capacity: Optional[Int] = none
    fn enqueue(value: T) -> Bool:
    fn dequeue() -> Optional[T]:
    fn peek() -> Optional[T]:
    fn length() -> Int:
    fn is_empty() -> Bool:

PriorityQueue.capacity#

Constructor capacity in items; omission/none is unbounded, and supplied values must be positive.

Manuscript
capacity: Optional[Int] = none

PriorityQueue.compare#

Constructor comparator: negative puts left first; ties dequeue in enqueue order. Comparisons must stay consistent and must not mutate this queue.

Manuscript
compare: fn(left: T, right: T) -> Int

PriorityQueue.dequeue#

Removes and returns the next value by priority, or none when empty.

Manuscript
fn dequeue() -> Optional[T]:

PriorityQueue.enqueue#

Adds a value, returning false when a bounded queue is full.

Manuscript
fn enqueue(value: T) -> Bool:

PriorityQueue.is_empty#

Reports whether the queue has no values to peek or dequeue.

Manuscript
fn is_empty() -> Bool:

PriorityQueue.length#

Returns the number of enqueued values, independent of their priorities.

Manuscript
fn length() -> Int:

PriorityQueue.peek#

Returns the next value by priority without removing it, or none when empty.

Manuscript
fn peek() -> Optional[T]:

Queue Native type#

A local mutable FIFO queue; protect all shared access with Synchronized. Omitted or none capacity grows as needed and adds no fixed queue limit.

Manuscript
type Queue[T]:
    capacity: Optional[Int] = none
    fn enqueue(value: T) -> Bool:
    fn dequeue() -> Optional[T]:
    fn peek() -> Optional[T]:
    fn length() -> Int:
    fn is_empty() -> Bool:

Queue.capacity#

Constructor capacity in items; omission/none is unbounded, and supplied values must be positive.

Manuscript
capacity: Optional[Int] = none

Queue.dequeue#

Removes and returns the oldest value, or none when empty.

Manuscript
fn dequeue() -> Optional[T]:

Queue.enqueue#

Adds a value, returning false when a bounded queue is full.

Manuscript
fn enqueue(value: T) -> Bool:

Queue.is_empty#

Reports whether dequeue and peek would return none.

Manuscript
fn is_empty() -> Bool:

Queue.length#

Returns the number of values currently waiting in the queue.

Manuscript
fn length() -> Int:

Queue.peek#

Returns the oldest value without removing it, or none when the queue is empty.

Manuscript
fn peek() -> Optional[T]: