26 ms·
I recently wrote some multi-threaded code (for the first time) for a game I'm working on. Luckily the data I need to process is in a (C++) vector, so I was able
by YesBox 4y ago
I recently wrote some multi-threaded code (for the first time) for a game I'm working on. Luckily the data I need to process is in a (C++) vector, so I was able to break the data up by dividing the vector size by available cores. I certainly felt 10 ft. tall when it worked!
Another area of my code where concurrency will greatly benefit it requires updating an unordered_map. Since it's positioned based and not unit_id based, I'll need to figure out a way to prevent data races. The best option I've thought of so far is assigning thread numbers to each edge in my graph, and storing the units in each edge in a queue, which should prevent data races and car collisions. (edit: ha)
That being said, I'm the sole developer on this project and I cannot imagine working on a multi-threaded application with dozens of other developers. It is nice dipping my toes in the water though.
- jcelerier 4y agoThere are multiple concurrent map implementation available - the most known one in C++ is certainly TBB's : https://oneapi-src.github.io/oneTBB/main/tbb_userguide/concurrent_hash_map.html https://oneapi-src.github.io/oneTBB/main/tbb_userguide/concu...
- YesBox 4y agoNeat! Thanks, I will look into this