Skip to content

Commit 5466d3d

Browse files
vchuravygbaraldi
andauthored
Add note the Task about sticky bit (#50915)
Update the docs for `Task` to mention the fact that they default to sticky. Co-authored-by: Gabriel Baraldi <baraldigabriel@gmail.com>
1 parent 1c536dd commit 5466d3d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

base/docs/basedocs.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,12 @@ Create a `Task` (i.e. coroutine) to execute the given function `func` (which
17481748
must be callable with no arguments). The task exits when this function returns.
17491749
The task will run in the "world age" from the parent at construction when [`schedule`](@ref)d.
17501750
1751+
!!! warning
1752+
By default tasks will have the sticky bit set to true `t.sticky`. This models the
1753+
historic default for [`@async`](@ref). Sticky tasks can only be run on the worker thread
1754+
they are first scheduled on. To obtain the behavior of [`Threads.@spawn`](@ref) set the sticky
1755+
bit manually to `false`.
1756+
17511757
# Examples
17521758
```jldoctest
17531759
julia> a() = sum(i for i in 1:1000);

0 commit comments

Comments
 (0)