REGoth-project / REGoth

OpenSource-Reimplementation of the zEngine, used by the game "Gothic"
GNU General Public License v3.0
630 stars 63 forks source link

Rework async system #297

Closed markusobi closed 6 years ago

markusobi commented 6 years ago
markusobi commented 6 years ago

Should I refactor the whole executeInThread system into a separate class?

markusobi commented 6 years ago

@ataulien I've refactored the threading stuff into it's own class: JobManager The JobManager does not have any dependency (BaseEngine is forward declarated). The BaseEngine has got a JobManager (public) member variable. The two execute functions executeInThread and executeInMainThread are still in the BaseEngine and are simply calling the JobManager's functions of the same name. Since they are only wrapper functions, I could remove them and refactor all usages.

Which of the following variants do you prefer?

ataulien commented 6 years ago

@markusobi Sounds reasonable. I would prefer something along the lines of m_Engine.getJobManager().executeInMainThread<void>(...).

Having the method directly inside the engine would make the code less cluttered, on the caller-side, but it would also lead to a more bloated engine-object. We would have to wrap stuff like loading textures, etc too, to stay consistent.