commit | f46c2e6b915278a07dae62d81ba1e0abbfd3d696 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Tue Sep 24 23:14:54 2024 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Tue Sep 24 23:14:54 2024 +0000 |
tree | a85a9c6667fa53fe18f26c03c30d1a0b98c4c69b | |
parent | cab57673a9a0029fe75d44b647fbff86b07a9f8b [diff] | |
parent | 9a0bb7039e03aabe034955b7f22c611817f547b5 [diff] |
Snap for 12410557 from 9a0bb7039e03aabe034955b7f22c611817f547b5 to sdk-release Change-Id: Ic467a773201f5a131369f94c7e781e9bafcc93a7
A Future
s channel-like utility to signal when a value is wanted.
Futures are supposed to be lazy, and only starting work if Future::poll
is called. The same is true of Stream
s, but when using a channel as a Stream
, it can be hard to know if the receiver is ready for the next value.
Put another way, given a (tx, rx)
from futures::sync::mpsc::channel()
, how can the sender (tx
) know when the receiver (rx
) actually wants more work to be produced? Just because there is room in the channel buffer doesn't mean the work would be used by the receiver.
This is where something like want
comes in. Added to a channel, you can make sure that the tx
only creates the message and sends it when the rx
has poll()
for it, and the buffer was empty.
want
is provided under the MIT license. See LICENSE.