Skip to content

Commit 9a275a7

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 <[email protected]> (cherry picked from commit 5466d3d)
1 parent 8a80439 commit 9a275a7

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
@@ -1692,6 +1692,12 @@ Create a `Task` (i.e. coroutine) to execute the given function `func` (which
16921692
must be callable with no arguments). The task exits when this function returns.
16931693
The task will run in the "world age" from the parent at construction when [`schedule`](@ref)d.
16941694
1695+
!!! warning
1696+
By default tasks will have the sticky bit set to true `t.sticky`. This models the
1697+
historic default for [`@async`](@ref). Sticky tasks can only be run on the worker thread
1698+
they are first scheduled on. To obtain the behavior of [`Threads.@spawn`](@ref) set the sticky
1699+
bit manually to `false`.
1700+
16951701
# Examples
16961702
```jldoctest
16971703
julia> a() = sum(i for i in 1:1000);

0 commit comments

Comments
 (0)