Fabric API

Fabric API

106M Downloads

[Suggestion] ExecutorService or similar provided by fabric

moonheart08 opened this issue ยท 3 comments

commented

It would likely be a good idea to provide a centralized ExecutorService or similar for mods that wish to use threads, to help with the following:

  • Preventing buildup of a large number of threads, from each mod creating new threads
  • Centralizing the configuration of the aforementioned thread usage, so that the number of threads can easily be adjusted via a single config file.
  • Related to the first point, preventing so many threads from being spawned (Usually occurs simply by spawning one or two more than there are cores) that extra threads become ineffective and simply give the JVM more work.
commented

@moonheart08 What's your use case?

I have a library for server-side concurrency I plan to port to 1.14 but it hasn't been at the top of my priority list. I could probably get it out this weekend if someone really needs it. Here's the core of it for illustration.

I do not plan to submit it as a Fabric PR because it's designed to handle extreme parallelism. (It runs the fluid simulator behind this monstrous beast). If you just need the occasional off-thread task the solution @asiekierka suggested should be sufficient.

commented

The server exposes an Executor for "server workers" - is that insufficient?

commented

@asiekierka it does? I must have not noticed. That's my fault. Thanks for pointing that out.