eventhorizon5 / skyscraper

The Skyscraper Project (Skyscrapersim) - an open source building, city, and elevator simulator
https://www.skyscrapersim.net
GNU General Public License v2.0
28 stars 7 forks source link

Multithreading #36

Open eventhorizon5 opened 1 year ago

eventhorizon5 commented 1 year ago

Due to a fix to the Console::Write function (I added a mutex lock around the function for thread safety), I've enabled WorkQueue multithreading in Ogre, which requires a rebuild of Ogre. If you still haven't yet, rebuild Ogre with OGRE_CONFIG_THREADS=3 which is the default.

Previously wxWidgets would crash in the Console code due to multiple Ogre threads trying to call the Write function simultaneously, but due to the mutex fix, it now works properly since the threads are now synchronized.

Since Ogre will support multithreaded workqueues with that, I'll see if I can utilize them to multithread portions of Skyscraper. I've also wanted to run each sim engine in a thread, but am not yet sure how to do that safely (so far I know that some code such as the render buffer code needs to be only called from the primary thread).

eventhorizon5 commented 1 month ago

Current multithreading work (4th attempt so far) is in the 'threading2' branch. This code is aiming for inclusion in the 2.1 codebase, if it can become working and stabilize.