commit | aca93a786f2d07e2ac44df659d3ee3746c8bbab2 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Mon Sep 23 23:17:41 2024 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Mon Sep 23 23:17:41 2024 +0000 |
tree | a85a9c6667fa53fe18f26c03c30d1a0b98c4c69b | |
parent | e406b664ef64f94094554111a2c2d80fce891e6d [diff] | |
parent | f4f6abf7214835747bc789c55fde9e9581f7d6c4 [diff] |
Snap for 12404440 from f4f6abf7214835747bc789c55fde9e9581f7d6c4 to 24Q4-release Change-Id: I9b4f4485491c27cf22cd15119d2d687826f1f365
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.