Std.Queue
effect Queue[A]Values of type A in order, up to a capacity. dbg shows the capability as <queue>.
-
suspend fn offer(value: A) -> () fails QueueClosedAdds
valueat the end. Waits while the queue is full. Fails withQueueClosedif the queue is closed, or is closed while this waits; the value is then not added. -
suspend fn take() -> A fails QueueClosedRemoves the value at the front and returns it. Waits while the queue is empty. Fails with
QueueClosedonce the queue is closed and empty. -
fn try_offer(value: A) -> BoolAdds
valueand returns True if the queue is neither full nor closed. Otherwise returns False and adds nothing. Does not suspend. -
fn poll() -> Option[A]Removes the value at the front and returns it as
Some, or returnsNoneif the queue is empty. Does not suspend. -
fn size() -> IntThe number of values in the queue.
-
fn close() -> ()Closes the queue. The values in it can still be taken. Closing a closed queue does nothing.
handler Queue[A]: Queue[A]init(capacity: Int)Makes an empty queue that holds up to capacity values. capacity less than 1 is a defect.
Its release does nothing.
QueueClosed
Section titled “QueueClosed”error QueueClosedThe queue is closed (and, for take, empty).