Expand description
sigq is a FIFO queue that supports pushing and poping nodes from
threads/tasks, crossing sync/async boundaries. The interface to interact
with the queue is a pair of end-points. The Pusher
is used to add data
to the queue, and the Puller
is used to pull data off the queue.
The Pusher
has a push()
method that is used to push new
nodes onto the queue.
The Puller
has a blocking pop()
and a
apop()
that returns a Future
for getting the next node
off the queue. These will return immediately with the next node if
available, or block and wait for a new node to be pushed onto the queue.
try_pop()
can be used as a non-blocking way to get the
next node, if available.
let (pusher, puller) = sigq::new();
pusher.push(42).unwrap();
assert_eq!(puller.pop(), Ok(42));
assert_eq!(puller.try_pop(), Ok(None));
§Semantics
- Dropping the last
Pusher
end-point will cause waitingPuller
’s to wake up and returnErr(StaleErr)
if there are no more nodes on the queue. - Dropping the last
Puller
end-point will:- Immediately drop all the nodes in the queue.
- Cause the
Puller
’s to returnErr(StaleErr)
if new nodes are attempted to be added to the queue.
Structs§
- Must
Handle - Wrapper around elements that must be handled by the application.
- Puller
- The receiving end-point of queue.
- Pusher
- The transmitting end-point of queue.
- Stale
Err - Error value used to indicate that there are no remote end-points available.
- Weak
Pusher - A weak reference to a
Pusher
.
Functions§
- new
- Create a new queue and return its paired push and pull objects.