Giter Site home page Giter Site logo

Comments (7)

sebas77 avatar sebas77 commented on May 10, 2024

All the operations [add and delete] now happens always the next submit operation. Today I am going to commit another fix/change of behavior to be sure that everything is in-line with this, however deleting items next iteration has been there for quite a while now.

from svelto.ecs.

sebas77 avatar sebas77 commented on May 10, 2024

is this still happening?

from svelto.ecs.

fenglinnet avatar fenglinnet commented on May 10, 2024

It still happens. At the same time, the delete operation is performed first. At this point, the add operation has not been performed, so the group cannot be found. I hope my broken English has been made clear...

from svelto.ecs.

sebas77 avatar sebas77 commented on May 10, 2024

Can I see your code? My understanding is that on the same frame you do two operations on the same entity which is something I reckon should never happen

from svelto.ecs.

fenglinnet avatar fenglinnet commented on May 10, 2024

You're right. We haven't used it in the project yet, but we do some pre-research based on survival example. This may be rare in real project. However, we believe that extreme cases are still possible, especially in the case of multi-thread. Maybe it would be better if the engine solved it. Anyway, this is my personal opinion :)

Here's our test code,

        void BuildRandomIsland(IFleetComponent fleet, int islandCount)
        {
            var point = fleet.points[fleet.pointIdx];
            var info = new UnmovableInfo
            {
                position = point
            };
            for (int i = 0; i < islandCount; i++)
            {
                var data = this._islandDatas[Random.Range(0, this._islandDatas.Length - 1)];

                info.position.x += Random.Range(-MAX_RANDOM_RANGE, MAX_RANDOM_RANGE);
                info.position.z += Random.Range(-MAX_RANDOM_RANGE, MAX_RANDOM_RANGE);
                info.rotation.y = Random.Range(-MAX_RANDOM_RANGE, MAX_RANDOM_RANGE);
                string key = _actorFactory.Build(data, ref info, ECSGroups.ActiveEnemies);

                this._islands.Enqueue(key);
            }
        }

        void ClearUnusedIsland()
        {
            while (this._islands.Count > MAX_QUEUE_COUNT)
            {
                var key = this._islands.Dequeue();
                _actorFactory.Remove<UnmovableEntityDescriptor>(key, ECSGroups.ActiveEnemies);
            }
        }

from svelto.ecs.

sebas77 avatar sebas77 commented on May 10, 2024

OK. It's unusual, obviously removing the excess in this case is weird. I can fix the problem, but it would make the building of the entities much slower.

For multithreading it's a different problem. the EnginesRoots are not thread safe, so if you want to add and remove from other threads, you will need at least to create your specialized Entity Scheduler in such away adding and remove is thread safe inside a specific thread.

I don't think massive parallelism is ever needed to add and remove entities, I suggest use synchronization points instead.

This is in theory tho, as in practice I never added and removed entities from other threads, although the next example I want to develop will be totally multithreaded so I can investigate more cases.

Please let me know what you think about all of this. Currently your code would crash by design, but I would need a pretty strong argument to fix it as it would make build entities slower.

from svelto.ecs.

fenglinnet avatar fenglinnet commented on May 10, 2024

Understand. I think we can avoid these problems in the project.

from svelto.ecs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.