Skip to content

Commit 78ae4dc

Browse files
vchuravygbaraldi
authored andcommitted
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> (cherry picked from commit 5466d3d)
1 parent fc452e7 commit 78ae4dc

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
@@ -1744,6 +1744,12 @@ Create a `Task` (i.e. coroutine) to execute the given function `func` (which
17441744
must be callable with no arguments). The task exits when this function returns.
17451745
The task will run in the "world age" from the parent at construction when [`schedule`](@ref)d.
17461746
1747+
!!! warning
1748+
By default tasks will have the sticky bit set to true `t.sticky`. This models the
1749+
historic default for [`@async`](@ref). Sticky tasks can only be run on the worker thread
1750+
they are first scheduled on. To obtain the behavior of [`Threads.@spawn`](@ref) set the sticky
1751+
bit manually to `false`.
1752+
17471753
# Examples
17481754
```jldoctest
17491755
julia> a() = sum(i for i in 1:1000);

0 commit comments

Comments
 (0)