Description
We want the ability to pin tasks to threads so that we can use libraries that expect the same thread to call into it (usually because they use TLS). Currently in Julia, there's no explicit interface to do this and Base.@async
is often used for this purpose. However, that interface carries additional (and problematic) semantics and really should not be used for this purpose (or at all).
Golang has LockOSThread and UnlockOSThread. We should add a similar interface, e.g. pintask()
and unpintask()
.
Ideally, these would not use the current sticky
field in Task
because that is inextricably tied up with Base.@async
semantics (e.g. task stickiness can spread to other tasks -- pinning and unpinning should do no such thing). Although it will complicate the implementation to have separate sticky
and pinned
options, it will make removing task stickiness altogether much easier.
Opening this issue to solicit opinions from the community for discussion.