-
This is from the documentation for
? Since there is no transition from not-ready to ready after the It's possible I'm misunderstanding something about this, would appreciate if someone sheds some light on this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
We have thought of this of course :) Tokio uses a counter for the number of readiness events to avoid this race condition. To perform a read, it does these things:
When you call |
Beta Was this translation helpful? Give feedback.
We have thought of this of course :)
Tokio uses a counter for the number of readiness events to avoid this race condition. To perform a read, it does these things:
When you call
.await
onreadable()
, it will wait until the readiness counter becomes larger than the value stored in step 3. If it's already larger, then it returns immediately. This means that any readiness event that happened after step 1 (so including events during step 2), will be enough forreadable().await
to return immediately.