Owned version of Notified<'_>
#7231
Labels
A-tokio
Area: The main tokio crate
C-feature-request
Category: A feature request.
M-sync
Module: tokio/sync
Several times I've found myself frustrated with
Notify
semantics.Notify::notify_waiters
allows for notifying only thoseNotified
instances that were acquired before the call. This makes it hard to use this interface when working with background tasks.Example:
In the snippet above, spawned background tasks may not pick up the notification from the
Notify::notify_waiters
call. It seems to me thatNotify
was designed specifically for this kind of problems. However, the interface does not allow for a safe solution, asNotified
cannot be sent between tasks.I can work around this problem by using other primitives, like a
Semaphore
or aShared<oneshot::Receiver>
that never receives any value (instead, waits for the sender to be dropped), but I thinkNotify
would be much simpler and easier to understand.Would be nice to have an owned version of
Notified
, e.g like this:If this sounds ok, I'm willing to implement it
The text was updated successfully, but these errors were encountered: