Skip to content
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 sticky task warning to @task and schedule #54815

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,8 @@ The task will run in the "world age" from the parent at construction when [`sche
!!! warning
By default tasks will have the sticky bit set to true `t.sticky`. This models the
historic default for [`@async`](@ref). Sticky tasks can only be run on the worker thread
they are first scheduled on. To obtain the behavior of [`Threads.@spawn`](@ref) set the sticky
they are first scheduled on, and when scheduled will make the task that they were scheduled
from sticky. To obtain the behavior of [`Threads.@spawn`](@ref) set the sticky
bit manually to `false`.
# Examples
Expand Down
14 changes: 14 additions & 0 deletions base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ end
Wrap an expression in a [`Task`](@ref) without executing it, and return the [`Task`](@ref). This only
creates a task, and does not run it.
!!! warning
By default tasks will have the sticky bit set to true `t.sticky`. This models the
historic default for [`@async`](@ref). Sticky tasks can only be run on the worker thread
they are first scheduled on, and when scheduled will make the task that they were scheduled
from sticky. To obtain the behavior of [`Threads.@spawn`](@ref) set the sticky
bit manually to `false`.
# Examples
```jldoctest
julia> a1() = sum(i for i in 1:1000);
Expand Down Expand Up @@ -991,6 +998,13 @@ the woken task.
It is incorrect to use `schedule` on an arbitrary `Task` that has already been started.
See [the API reference](@ref low-level-schedule-wait) for more information.
!!! warning
By default tasks will have the sticky bit set to true `t.sticky`. This models the
historic default for [`@async`](@ref). Sticky tasks can only be run on the worker thread
they are first scheduled on, and when scheduled will make the task that they were scheduled
from sticky. To obtain the behavior of [`Threads.@spawn`](@ref) set the sticky
bit manually to `false`.
# Examples
```jldoctest
julia> a5() = sum(i for i in 1:1000);
Expand Down