-
Notifications
You must be signed in to change notification settings - Fork 30
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
TaskSupport overridden in ForkJoinTasks #160
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9727?orig=1 |
@soc said (edited on Apr 5, 2016 1:43:02 PM UTC): Only slightly related to this, I think the mutable bits (mostly taskSupport) need to be cleaned up and removed, and a better immutable way should be provided. |
@szeiger said: |
@soc said: |
When porting from scala 2.11 to 2.12.12, we found something similar. Here is a simple piece of code to reproduce the problem.
|
is the problem also reproducible on Scala 2.13.5? |
scala/bug#11036 |
Yes it does.. |
The umbrella issue for TaskSupport ergonomics might be #152 Probably @SethTisue intended to close this ticket with other module-related tickets? I tried to follow the conclusions from a few years ago. For A workaround is to call Here is the updated snippet. The printlns make it easier to see order of operations. In the absence of blocking, the outer loop happily submits tasks, and the FJP may spawn an extra thread or 2 to ensure parallelism. It's crucial to distinguish tasks from the threads. I assume the expectation or goal is to run 2 tasks on 2 threads, with the next task (or foreach iteration) running when a thread is available.
|
This is an interesting solution but not one that is possible given the current code I use. The inner loop is not directly accessible. My workaround is kind of the opposite of your code sample.. I execute the top level loop with futures on a fixed execution pool and leave the inner code do whatever it wants. |
I agree your solution is best. The promise of |
The wrong forkJoinPool is used in the following example:
In Tasks.scala, we see at line 420:
https://github.com/scala/scala/blob/5cb3d4ec14488ce2fc5a1cc8ebdd12845859c57d/src/library/scala/collection/parallel/Tasks.scala#L420
Which overrides the given tasksupport, preferring the executioncontext of the currentThread.
The text was updated successfully, but these errors were encountered: