...is a simple-yet-powerful state management system based around the HandlerPool.
Time after time I see the broken state-machine approach games and libraries use like OpenGL.
While this initially works, once more than one source affects one state, the state will be reverted earlier than expected.
Take something like this:
Runnable someCallback = () -> {
entity.setSomeProperty(true);
entity.doCalculation();
entity.setSomeProperty(false);
};
entity.setSomeProperty(true);
entity.doCalculation(); // I expect `someProperty` to be true.
someCallback.run();
entity.doOtherCalculation(); // Oops! - someProperty was set to false too early.
entity.setSomeProperty(false);
With FlowPoolAPI, this same logic would be:
// entity.someProperty is a `PoolToggle`
HandlerPool pool = new HandlerPool();
HandlerPool callbacksPool = new HandlerPool();
Runnable someCallback = () -> {
entity.someProperty.push(callbacksPool);
entity.doCalculation();
callbacksPool.close(); // or entity.someProperty.pop(pool);
};
entity.someProperty.push(pool);
entity.doCalculation();
someCallback.run();
entity.doOtherCalculation(); // entity.someProperty is still true!
pool.close(); // entity.someProperty set to false
Notice how each state manipulator hold its own HandlerPool
.
Alongside PoolToggle
, there's PoolList
and PoolStack
for basic collections, and PoolPipeline
for handler-based execution pipelines.
Find more about it in the wiki!
Add the maven repo:
maven {
name "teamcelestial-public"
url "https://maven.teamcelestial.org/public"
}
And find the latest Gradle/Maven dependency here: https://maven.teamcelestial.org/#/public/me/thosea/flowpool/flowpoolapi
It requires Java 17 or higher.
Find the javadoc link for your version on the release page: https://github.com/ItsThosea/flowpoolapi/releases
None of these are thread-safe! You are responsible for enforcing thread safety yourself.
An AI generated it.