Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add thread-pool capabilities to scope #64

Closed
TyOverby opened this issue Apr 9, 2016 · 7 comments
Closed

Add thread-pool capabilities to scope #64

TyOverby opened this issue Apr 9, 2016 · 7 comments

Comments

@TyOverby
Copy link

TyOverby commented Apr 9, 2016

Maybe with an API like

let pool = Pool::new(8); // 8 threads in the pool.
pool.scoped(|scope| {
    scope.spawn(...);
});
@teburd
Copy link

teburd commented Apr 13, 2016

+1

@upsuper
Copy link

upsuper commented May 24, 2016

It would probably also be useful to allow user to control which task goes to which thread, for example, something like

let pool = Pool::new(8);
pool.scoped(|threads| {
    for (thread, task) in threads.iter().zip(tasks.iter()) {
        thread.dispatch(task);
    }
});

@upsuper
Copy link

upsuper commented May 24, 2016

One use case of thread pool can be seen in bryant/argon2rs, where fixed number of threads need to be synchronized frequently, which isn't quite doable with crossbeam right now.

@jeehoonkang
Copy link
Contributor

FYI, probably this is one of the most relevant crates to this issue: https://github.com/Kimundi/scoped-threadpool-rs . Also there is a discussion on various Rust libraries on cpu pools: rust-lang/futures-rs#411

@jeehoonkang
Copy link
Contributor

Also related: https://docs.rs/rayon/0.9.0/rayon/fn.scope.html . At least, we need to write a better documentation as done in Rayon.

@ghost
Copy link

ghost commented Sep 30, 2018

The library ecosystem has evolved quite a bit since this question was asked. Tokio is now the thread pool for async IO and Rayon is the thread pool for parallel CPU-intensive tasks.

Since we already have two universal thread pools that cover a wide range of use cases, I don't see a need for creating another one. Even if neither Tokio nor Rayon are good enough for a particular use case, then a simple thread pool provided by Crossbeam probably won't be either.

Should we close this issue?

@ghost ghost closed this as completed Oct 9, 2018
exrook pushed a commit to exrook/crossbeam that referenced this issue Oct 7, 2020
@nhukc
Copy link

nhukc commented Jun 14, 2024

I don't think this is resolved.

Rayon does not work for cases where a mutex is required due to work stealing. A non-work-stealing scoped thread pool implementation would be extremely useful for writing userspace rust drivers.

See rayon-rs/rayon#1174 for additional details.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants