-
Notifications
You must be signed in to change notification settings - Fork 506
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
Scopes and blocking operations #835
Comments
We've talked about having having a scope that always runs on the parent thread, but we never added it. I'm trying to remember the details why we did not, @cuviper may recall if there are particular reasons. |
See #562 to allow working without |
I suddenly find my program stuck because the machine has only one CPU core. Setting |
Rayon 1.5.1 now has |
|
I've run into a problem with scopes. It looks like
scope
switches to one of the thread-pool threads for its body. So if the body does any blocking operation, it is possible to run into a deadlock.Example 1: I'd like to spawn a bunch of tasks on the thread-pool inside the scope so they can access the outer variables. Because processing is much slower than producing, this quickly pushes thousands of tasks into rayon queue and memory consumption is high. So I wanted to limit the number of tasks produced to a number low enough that memory is not a problem, but also high enough to allow parallel processing. Unfortunately any attempt to block the producer loop would cause a deadlock if rayon pool is sized to 1 thread.
Example 2: Spawning multiple tasks that send the results to the channel and receiving the results serially. I can't put the receiver loop inside the scope, because it can block and again - deadlock is possible if the pool is sized to only 1 thread.
Is there any way to get around this limitation?
Perfectly if scope did not switch to a thread pool thread, but ran the body on the parent thread would solve this.
The text was updated successfully, but these errors were encountered: