Deprecate Base.@async
#52109
Labels
deprecation
This change introduces or involves a deprecation
julep
Julia Enhancement Proposal
multithreading
Base.Threads and related functionality
Julia does need the ability to pin a task to a thread (in our current terminology: make it sticky). This currently happens implicitly for tasks created with
Base.@async
to support its semantics. To support those semantics, the parent task must also be made sticky. More precisely, if a newly created taskS
is sticky (which they are when created withTask()
or@task
), then whichever task callsschedule(S)
will also be made sticky. A task that calls theAsyncCondition(callback)
constructor (which spawns an@async
task) will become sticky, as will a task that callsTimer(callback)
.This sort of stickiness-infection ignores threadpool boundaries -- a task created on the default threadpool can end up being stuck to an interactive thread.
We can fix some of these (as we have previously), but we cannot fix them all, due to
@async
semantics.Furthermore, such stickiness-infected tasks are never unstuck. There is this PR which attempts to unstick such tasks, but adds too much overhead.
We should introduce an explicit task pin/unpin interface (see #52108) and deprecate
Base.@async
so that all this implicit stickiness and associated cruft can be removed from the runtime.The text was updated successfully, but these errors were encountered: