Skip to main content
GameDev.net gamedev.net
🔒 Locked

Threading in component based systems

Started by Nuno Leiria Apr 9, 2011 at 6:30 PM 1 replies 1k views
Original Post
Nuno Leiria
Nuno Leiria
Hi, I was wondering what would be the best approach to make a component system parallel. My idea is to make each component a "job" or task that could run in parallel with other tasks. One of my concerns is synchronization because ideally no locks should be used. If this was already discussed could you point me to the thread? I searched and found nothing.
KulSeran
KulSeran
You can do two levels of parallelism in a component system, there are components that can run in parallel and component instances that can run in parallel. The simplest thing to do is make sure that no instances can talk to each other within a component type. If they do have to talk to one another, use a lock-free message queue to deliver messages to be processed the next frame. That way you can just toss all instances into a thread pool, waiting on each type to finish the parallel update before launching the next type.
Nuno Leiria
Nuno Leiria
Could you elaborate on the difference between components and component instances?
And if you're waiting for a type of component to finish updating, suppose you have 4 threads and 3 of them finished updating that type. They could do no work because the remaining thread didn't finish updating that type and we didn't launch the next type. Did I misunderstood something?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.