DefaultEcs
DefaultEcs copied to clipboard
Async Tasks support
Hello, I'm very impressed with this ECS implementation, it's so flexible, really nice work.
I have an idea to try to use ECS with business applications creation.
To do so, I need asynchronous flow in systems in your library that uses Task
and ValueTask
as return values to be able to mark them async
.
What I can do is to make a new interface like IAsyncSystem<T>
, add a new method Task Run(T state)
into it, and call it manually. Also, I need to write my own "base systems" like ActionAsyncSystem
, SequentialAsyncSystem
etc...
But I definitely won't be able to use Publish/Subscriber model that supports only by World
.
I could write a separate library that will be able to extend DefaultEcs with async flows, but I can't see any extension points to extend Publish/Subscribe model behavior, because it defined only inside a World
and can't be overridden outside.
@Doraku what do you think about it? I assume it would be nice to add an extension point here.
hey! you mean like being able to provide your own IPublisher implementation to be used in a World? This is actually something I wanted to do at first (hence the IPublisher interface) but never went the extra miles. There is so many static tricks used that I am not even sure it is still doable. On the async part, from the start I didn't take that into account when designing DefaultEcs as async/await can allocate which is a big nono in games. There is no thread safe lock as you are expected to know what you are doing, relying on EntityCommandRecorder when needed, this might be difficult to handle with async/await too :/