Skip to content

scope without Send #562

@jonhoo

Description

@jonhoo

This ties somewhat into the discussion over in #522 (comment).

Currently, ThreadPool::scope requires the passed closure to be Send because the closure itself is executed on the thread pool. However, if ThreadPool is used as a more generic thread pool (rather than explicitly for data-dependent computation), it is not unreasonable for some existing thread to wish to spin off a number of jobs with access to its stack, and then wait for them all to complete (essentially as a pool of scoped threads). With the Send bound in place, that thread is pretty restricted in what it can use to generate jobs (e.g., anything with Rc is a no-go). It'd be good if there was an alternate version of scope that did not require Send for its closure, and which instead executed the closure on the current thread (but still waited for any spawned jobs to complete).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions