You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Java's parallelStream() method accesses the ForkJoinPool.commonPool when distributing the work, but this thread pool has the incorrect classloader when being used in an environment with Modules. This makes parallelStream() effectively unusuable.
We should provide a native ForkJoinPool with the correct classloader that can be used to execute parallel streams as a utility class, such as this one from FastSuite. This version is an extension of the original from Aequivaleo.
The text was updated successfully, but these errors were encountered:
Given that a parallel stream executed inside a forkjoinpool task works just fine out of the box -- would it be possible to just run mod ctors in a forkjoinpool with the proper classloader and whatnot so that parallel streams works out of the box? I may be misunderstanding something about how parallel mod event dispatch works. The forkjoinpool seems to be set up in ModWorkManager -- would there be a way to make that set the thread context classloader to the relevant mod classloader when executing something?
That would only be relevant for mod construction. If you attempt to use parallelStream() anywhere in your mod's code, you have to ensure that it is running inside a ForkJoinPool task with the correct context classloader, hence the need for the utility.
Java's
parallelStream()
method accesses theForkJoinPool.commonPool
when distributing the work, but this thread pool has the incorrect classloader when being used in an environment with Modules. This makesparallelStream()
effectively unusuable.There is a workaround, which is to execute
parallelStream()
inside of aForkJoinPool
task, which forces it to use the executing pool instead of falling back to the common pool. See https://stackoverflow.com/questions/21163108/custom-thread-pool-in-java-8-parallel-streamWe should provide a native
ForkJoinPool
with the correct classloader that can be used to execute parallel streams as a utility class, such as this one from FastSuite. This version is an extension of the original from Aequivaleo.The text was updated successfully, but these errors were encountered: