Separate thread module loading#270
Separate thread module loading#270getcetc wants to merge 3 commits intocortex-command-community:developmentfrom
Conversation
HeliumAnt
left a comment
There was a problem hiding this comment.
Cool!
also linux/macos fixes needed
| /// Inclusions of header files | ||
| #include "Entity.h" | ||
| #include "Singleton.h" | ||
| #include "shader.h" |
There was a problem hiding this comment.
forward declare class Shader instead. And #include "Shader.h" in cpp
| reader >> ClassName; | ||
| pClass = Entity::ClassInfo::GetClass(ClassName); | ||
| if (ClassName == "Shader") { | ||
| int a = 5; |
There was a problem hiding this comment.
???? (though if you really need this empty check to happen use (void); instead)
There was a problem hiding this comment.
Ahh this was to set a breakpoint on it 😅
| while (1) { | ||
| mainThreadHeartbeat++; | ||
| PollSDLEventsCallback(); | ||
| if (true) { |
There was a problem hiding this comment.
no need for the if (true). you can just make a code block, that's still local scope.
There was a problem hiding this comment.
A very non-production PR from me, sorry! This and other things i intended not to have left in. Will fix up, thank you for great feedback!
| } else if (spinlockDetected) { | ||
| spinlockDetected = false; | ||
| SpinlockAssert(toDoProgressPrintOut, loadingDone); | ||
| RTEAssert(false, to_string(mainThreadHeartbeat)) |
There was a problem hiding this comment.
Btw we have RTEAbort for this usecase
There was a problem hiding this comment.
I learn more things 🙂
Will use!
The module loading work is now done in a worker thread.
This speeds up loading progress printout, if enabled. The is done by the worker thread only pushing the printout strings, while the main thread consumes and draws them out.
By consuming SDL events on the main thread, this:
This also sets up for future module loading multithreading work.
Asserts from worker thread work OK, but caution is to be taken on further MT work. Some scaffolding has been built for it.
Also implemented is a spinlock watchdog thread, asserting with useful info.