Expand description
Transmit any number of values of the same type, then (after transmitting all) proceed according to
a continuation session. The two sides, receiving and sending, are Dequeue
and Enqueue
, respectively.
The order of values popped out of Dequeue
is the same as their push order into Enqueue
– first-in,
first-out.
Pushing values into Enqueue
is always non-blocking – any number of values may be pushed without
waiting for Dequeue
to receive them.
These queue sessions are just a standardization of a common recursive pattern. They are fully equivalent to:
enum Queue<T, S: Session> {
Item(T, Dequeue<T, S>),
Closed(S),
}
// naked definitions of the two sides of the queue
type Dequeue<T, S> = Recv<Queue<T, S>>;
type Enqueue<T, S> = Send<Queue<T, Dual<S>>>;
Structs§
- Dequeue
- Produces an arbitrary number of values of type
T
, then proceeds according toS
. Its dual isEnqueue<T, Dual<S>>
. - Dequeue
Stream - A
Stream
ofNext<T, S>
producing all items from the queue before producing its final continuation. - Dequeue
Stream1 - A
Stream
producing all items from aDequeue
. - Enqueue
- Accepts an arbitrary number of values of type
T
, then proceeds according toS
. Its dual isDequeue<T, Dual<S>>
.
Enums§
- Next
- The
Stream::Item
ofDequeueStream<S, T>
, distinguishing between a popped item and a closed queue with its final continuation. - Queue
- The result of
Dequeue::pop
.