Skip to content

Explicit task pin/unpin interface #52108

Open
@kpamnany

Description

@kpamnany

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    julepJulia Enhancement ProposalmultithreadingBase.Threads and related functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions