Dex.Channel¶
- Subclasses:
None
Methods¶
- Inherited:
class |
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
None
Fields¶
None
Class Details¶
- class Dex.Channel¶
- Bases:
- Abstract:
No
- classmethod new(capacity)¶
- Parameters:
capacity (
int
) – the channel queue depth or 0 for unlimited- Returns:
a new
Dex.Channel
- Return type:
Creates a new
Dex.Channel
.If capacity is non-zero, it can be used to limit the size of the channel so that functions can asynchronously stall until items have been removed from the channel. This is useful in buffering situations so that the producer does not outpace the consumer.
- close_receive()¶
- close_send()¶
- receive()¶
- Returns:
- Return type:
Receives the next item from the channel.
The resulting future will resolve or reject when an item is available to the channel or when send side has closed (in that order).
- receive_all()¶
- Returns:
- Return type:
Will attempt to receive all items in the channel as a #DexResultSet.
If the receive side of the channel is closed, then the future will reject with an error.
If there are items in the queue, then they will be returned as part of a #DexResultSet containing each of the futures.
Otherwise, a
Dex.FutureSet
will be returned which will resolve or reject when the next item is available in the channel (or the send or receive sides are closed).
- send(future)¶
- Parameters:
future (
Dex.Future
) – aDex.Future
- Returns:
- Return type:
Queues future into the channel.
The other end of the channel can receive the future (or a future that will eventually resolve to future) using
Dex.Channel.receive
().This function returns a
Dex.Future
that will resolve when the channels capacity is low enough to queue more items.If the send side of the channel is closed, the returned
Dex.Future
will be rejected withDex.Error.CHANNEL_CLOSED
.