-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add docs on task migration #50047
add docs on task migration #50047
Conversation
Would it be a good idea to suggest an alternative to indexing using |
Yeah. There's a bit of a concerted effort going on currently to help clarify behavior and guidance on that. One part is #48542. Another is a guide post that's being drafted. |
[`@threads`](@ref Threads.@threads)), it may move to a different thread if the task yields. | ||
|
||
This means that [`threadid()`](@ref Threads.threadid) should not be treated as constant within a task, and therefore | ||
should not be used to index into a vector of buffers or stateful objects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we say "Instead, prefer making judicious use of task_local_storage()
, or pass values around as explicit arguments."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what we should advise is that people use @spawn
because @spawn
ed tasks can define and return values.
That's a lot nicer as an API than having users trying to reason about shared buffers, or them trying to reach into and keep track of task_local_storage()
s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could keep this PR as is then figure out the recommended patterns in #48542?
(cherry picked from commit ff23b37)
(cherry picked from commit ff23b37)
(cherry picked from commit ff23b37)
#40715 introduced task migration (in 1.7)
#43496 removed pre-1.7 docs that said task migration didn't happen
It seems important-enough and surprising-enough to explicitly document.