frengels / matter

C++20 highly parallel ECS implementation
20 stars 0 forks source link

Layering buffered changes #98

Open frengels opened 5 years ago

frengels commented 5 years ago

Because of the immutability guarantees on the iterated groups certain kinds of jobs, such as the ones to be executed in parallel will need to be buffered in a new group_container. And each nested parallel job after this will get the original and the newly created group_container passed.

Ideally there will be a method to hide these layers of containers from the next job. For this we can collect all the groups into a vector or similar contiguous data layout. group_container already offers a range since #96 and we can easily copy the groups from this range. Access to underlying layers can also be obtained through a range.

// base wrapper around a group_container
class group_container_wrapper
{
    group_container& grp_cont;
    group_container grp_buffer;

    // created on construction
    std::vector<any_group> view_cache;

    auto range() { return view::all(view_cache); }
};

template<UnderlyingGroupWrapper>
class layered_group_container
{
    // the template parameter
    group_wrapper& wrap;

    // buffer for this layer
    group_container buffer;

    // collect range from wrapped and our buffer
    std::vector<any_group> view_cache;

};
frengels commented 5 years ago

I'm going to cancel most of this for now. I think it is useful to keep this as simple as possible. So for now I'll decide that only read and write actions can be performed concurrently if they don't violate each other's integrity. Other than that all actions such as create, destroy, detach, attach will have to run in sequence unless marked as unsafe.

A benefit will be a simple initial design which doesn't require us to layer stages of changes.