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
Anything more than a simple demo will probably have some soft of a System trait, with objects implementing it being boxed and stored in a list to be executed automatically. It may look like this:
Unfortunately, using secs under such abstraction is not elegant:
The system execution is now split into 3 different chunks, executed at different moments:
process() entry, executed upon queuing the system
fetch phase, executed at the start of the system on another thread
iter phase, executed after all the storage locks are acquired
Any data that system has (and wants to access in the execution closure) needs to be Clone + Sync. Imaging a mutable vector there - now you'd need to wrap it into Arc<Mutex<X>> , even though it should not be needed. This is inconvenient and bloats the code.
Optimally, I'd like to base ECS onto the system interface like this (edit: moved to #40):
traitSystem<C:Clone>:Send{//`C` stands for "Context"typeData<'a>;// some sort of HKT, which is not supported in current Rustfnfetch<'a>(&self,&'a secs::World) -> Self::Data<'a>;fnrun(&mutself,Data<'a>,C);}
Why this would be nice:
this system is required to implement Send: each time it needs to be executed, it's moved onto the thread, run, and then moved back (or not, if we can track this).
it allows any sort of data to be kept within the system without harsh restrictions or bloated wrappers
it clearly separates executable parts and their contexts. This enforces a fetch at compile time.
it allows the users to start using it right away (without higher abstractions) in complex systems, one just need to decide what C is (in the original example, C = TimeDelta)
The text was updated successfully, but these errors were encountered:
Anything more than a simple demo will probably have some soft of a
System
trait, with objects implementing it being boxed and stored in a list to be executed automatically. It may look like this:Unfortunately, using
secs
under such abstraction is not elegant:process()
entry, executed upon queuing the systemfetch
phase, executed at the start of the system on another threaditer
phase, executed after all the storage locks are acquiredClone + Sync
. Imaging a mutable vector there - now you'd need to wrap it intoArc<Mutex<X>>
, even though it should not be needed. This is inconvenient and bloats the code.Optimally, I'd like to base ECS onto the system interface like this (edit: moved to #40):
Why this would be nice:
Send
: each time it needs to be executed, it's moved onto the thread, run, and then moved back (or not, if we can track this).fetch
at compile time.C
is (in the original example,C = TimeDelta
)The text was updated successfully, but these errors were encountered: