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 understand wake up runnable immediately unconditionally will waste a lot of CPU, but I have a good reason to do it in my case.
The problem here is poll_once returns 0 after random duration, and probably cannot last for 1 second. That means the task disappeared in the system at some instant. According to my observation it never appear again after that, even when channel tx send new message.
One interesting point is that when simplify async task into futures::pending() it never disappear. Is there anything I did incorrect?
The text was updated successfully, but these errors were encountered:
I could indeed reproduce this, but I have a theory: I suspect this might happen if the call to waker.wake() happens while the task is being concurrently woken by the sender. When this happens, the first caller to wake (in this case the sender thread) is responsible for scheduling the task.
In such scenario, the task may not be visible in the queue yet the next time poll_once is called, possibly because the sender was pre-empted before it could re-schedule the task, or because of inter-thread communication latency, or simply because the scheduling process takes more instructions. So my hunch is that this is a concurrency bug in the user code rather than in async-task.
Edit: I just realized that the queue is thread-local, so what happens is probably simpler. If at any moment the receiver finds an empty channel, it registers its waker and the next time the sender sends an item, the task is pushed to wrong queue (i.e. the queue owned by the sender thread).
Code for reproduce:
I understand wake up runnable immediately unconditionally will waste a lot of CPU, but I have a good reason to do it in my case.
The problem here is
poll_once
returns 0 after random duration, and probably cannot last for 1 second. That means the task disappeared in the system at some instant. According to my observation it never appear again after that, even when channel tx send new message.One interesting point is that when simplify async task into
futures::pending()
it never disappear. Is there anything I did incorrect?The text was updated successfully, but these errors were encountered: