Skip to content

Commit

Permalink
doc: recommend @spawn over @async (#44667)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf authored Mar 21, 2022
1 parent a6187ea commit 28f58e7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,14 @@ Values can be interpolated into `@async` via `\$`, which copies the value direct
constructed underlying closure. This allows you to insert the _value_ of a variable,
isolating the asynchronous code from changes to the variable's value in the current task.
!!! warning
It is strongly encouraged to favor `Threads.@spawn` over `@async` always **even when no
parallelism is required** especially in publicly distributed libraries. This is
because a use of `@async` disables the migration of the *parent* task across worker
threads in the current implementation of Julia. Thus, seemingly innocent use of
`@async` in a library function can have a large impact on the performance of very
different parts of user applications.
!!! compat "Julia 1.4"
Interpolating values via `\$` is available as of Julia 1.4.
"""
Expand Down

0 comments on commit 28f58e7

Please sign in to comment.