Sign in to follow this  
Pombal

Threading in component based systems

Recommended Posts

Pombal    280
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.

Share this post


Link to post
Share on other sites
KulSeran    3267
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.

Share this post


Link to post
Share on other sites
Pombal    280
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?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this