-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
add docs on task migration #50047
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -388,6 +388,18 @@ threads in Julia: | |
| This may require some transitional work across the ecosystem before threading | ||
| can be widely adopted with confidence. See the next section for further details. | ||
|
|
||
| ## [Task Migration](@id man-task-migration) | ||
|
|
||
| After a task starts running on a certain thread (e.g. via [`@spawn`](@ref Threads.@spawn) or | ||
| [`@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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we say "Instead, prefer making judicious use of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think what we should advise is that people use 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
|
|
||
| !!! compat "Julia 1.7" | ||
| Task migration was introduced in Julia 1.7. Before this tasks always remained on the same thread that they were | ||
| started on. | ||
|
|
||
| ## Safe use of Finalizers | ||
|
|
||
| Because finalizers can interrupt any code, they must be very careful in how | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.