Interrupts any fibers that are suspended on offer because the queue is
* at capacity.
Interrupts any fibers that are suspended on offer because the queue is
* at capacity. If any fibers are interrupted, returns true, otherwise,
* returns false.
Interrupts any fibers that are suspended on take because the queue is
* empty.
Interrupts any fibers that are suspended on take because the queue is
* empty. If any fibers are interrupted, returns true, otherwise, returns
* false.
Places the value in the queue.
Places the value in the queue. If the queue has reached capacity, then
* the fiber performing the offer will be suspended until there is room in
* the queue.
Retrieves the size of the queue, which is equal to the number of elements in the queue.
Retrieves the size of the queue, which is equal to the number of elements in the queue. This may be negative if fibers are suspended waiting for elements to be added to the queue.
Removes the oldest value in the queue.
Removes the oldest value in the queue. If the queue is empty, this will * return a computation that resumes when an item has been added to the queue.
* A
Queueis a lightweight, asynchronous queue. This implementation is * naive, if functional, and could benefit from significant optimization. * * TODO: * * 1. Investigate using a faster option thanQueue, becauseQueuehas *O(n)lengthmethod. * 2. Benchmark to see how slow this implementation is and if there are any * easy ways to improve performance.