You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm writing some low-level code which directly uses Task, task::current() and Task::notify(). I the code I'm currently dealing with, I have a queue of Tasks which are awaiting notification. Sometime a task will remove itself from that queue because its no longer interested in the event. The problem is that it may have picked up a notification which isn't going to use, but some other task on that queue does need to make progress.
At the moment, when it withdraws from the queue it just unconditionally notifies some other task on the queue to make sure there's progress. But it would be better if it could see if there's a pending notification and only then pass it on to a queued task.
Is there a way to do this in the current API? Failing that, would it make sense to add Task::is_notified() or equivalent?
The text was updated successfully, but these errors were encountered:
Have your subscribers hold the receiver, and when they're no longer interested, simply drop it. You can detect that condition when you go to "send" your "notification" to the subscriber, giving you the chance to grab the next subscriber from the list.
Yeah, it doesn't really help because there's always a window between calling it and actually dropping the Task. An external flag would work just as well since it needs extra coordination to make sure the wakeup isn't dropped.
Version
tokio 0.1.11
Platform
Linux x86-64
Subcrates
Description
I'm writing some low-level code which directly uses
Task
,task::current()
andTask::notify()
. I the code I'm currently dealing with, I have a queue of Tasks which are awaiting notification. Sometime a task will remove itself from that queue because its no longer interested in the event. The problem is that it may have picked up a notification which isn't going to use, but some other task on that queue does need to make progress.At the moment, when it withdraws from the queue it just unconditionally notifies some other task on the queue to make sure there's progress. But it would be better if it could see if there's a pending notification and only then pass it on to a queued task.
Is there a way to do this in the current API? Failing that, would it make sense to add
Task::is_notified()
or equivalent?The text was updated successfully, but these errors were encountered: