-
Notifications
You must be signed in to change notification settings - Fork 496
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
Get the global thread pool repeatedly (to pass to a function) #909
Comments
This doesn't work even once, because One thing you can do right now is make the pool argument optional: fn lots_of_work(pool: Option<&ThreadPool>) {
if let Some(pool) = opt_pool {
pool.scope(|s| do_scoped_work(s))
} else {
rayon::scope(|s| do_scoped_work(s))
}
} However, a caveat is that See also #841 proposing to expose the current pool handle, and we could possibly do similar for the explicit global pool. |
Does this mean that if the user did pool.scope(|s| do_scoped_work())
fn do_scoped_work() {
rayon::scope(|s| ...)
} then |
Correct, |
The user can also call |
Maybe this could be clarified in the documentation. |
Hmm, I think the point Documentation improvements are always welcome! |
Assume I am writing a library with a function
where the responsibility of configuring and selecting the thread pool is delegated to the caller.
The user can use the global thread pool via
but this can only be called once, because
build_global()
fails if used a second time.But I do not want the user to have to create a new thread pool every time, either.
What is the best way to allow the user to call the function with the default thread pool?
I could not find something like
where the user does not need to track his reference to the global pool forever.
The text was updated successfully, but these errors were encountered: