Replies: 1 comment
-
Most of the time, the value is stored inside the task local scope future. However, when you poll the scope future, it will temporarily move the value to a thread-local. When the poll on the scope future ends, the value is moved out of the thread-local. This means that whenever you are inside a call to poll on the task-local scope future, the value will be in the right thread-local. This allows you to access it. You can't access the value outside of the scope future, but that's okay. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
If I understand correctly, task locals are like thread locals, but they handle:
ThreadLocal
would be overwritten)ThreadLocal
being unset for the task)Can anyone explain the technical details of Tokio's implementation of
task_local!
?Beta Was this translation helpful? Give feedback.
All reactions