Proper Task-based scheduling in Sponge

I’d like to see proper task-based scheduling in Sponge. Tasks are a super powerful abstractions on top of a scheduler for defining work that needs to be done in the future. Bukkit had primitive support for tasks, but it lacked a continuation mechanism for invoking another task at the completion of a first. Where task continuations become particularly powerful is when switching threads to do work outside of the game loop and then returning control to the game loop to apply the results.

Here is a link to an overview of one implementation of the Task Asynchronous Programming pattern. Download Task-based Asynchronous Pattern from Official Microsoft Download Center

Theres actually a similar post on this involving Rx-Java, which is also about scheduling I believe.

I like this idea, but I think the best implementation would be an rx-like system on top of this task-based scheduling system. Tasks could also happen during the game loop, which Rx would be an abstraction on top of. They could additionally happen, as you said, outside of the game loop. I need to consider this further, but those are my current thoughts.

In the same vein, the Rx implementation could work with this as well. As I said before, a hybrid system would be awesome, and I’ll prototype an API.

1 Like

Maybe have a look at kilim Task and Scheduler types as inspiration.

Did you mean that one?