Well met!
This might be a rather basic question, but I can't seem to find an answer.
To put it simply, I've got two threads - one for the interface and one for the gameloop of my engine.
Most simple example I could think of:
I've got a button. When I press it, I want to move an object. So what an idiot like me would try is:
void spawnButton_Click(System::Object^ sender, System::EventArgs^ e) {
Control->ModelEditor->MoveModel("object1", 100, 0, 0);
}
Well, that works like 99% of the time. But sometimes, it crashes - when I try to change the position, while the rendering thread is reading it.
My workaround was to send a request to the gameloop, which it would process on its next runthrough in its own thread. That seems to be working, but it blows up the code by a big deal on the log run, since I have to make request-methods for every single method I want to be accessable from the outside of my engine.
I suppose, some other kind of cross-thread-safety is required here - but I couldn't find something that would be taking considerably less code than my approach. Everything regarding multithreading appears to be a huge pain in the butt to implement, so people try to keep thread-communication to a minimum.
What is the usual approach for this kind of high-traffic-multi-thread-communication? Do you got some good papers to link for help? Everything would be helpful.
Have a nice day!
-gnomgrol