SFML community forums
Help => Window => Topic started by: dobbi10k on April 29, 2012, 11:17:27 am
-
Hey guys,
I created a MT event handling system for my game engine. Basically in its thread it waits for events and then checks a map whether any part of the game / engine needs to know about the event. If so it pushes the event to the receivers event queu. Sounds great to me, but it doesn't work, unfortunately. It makes the window and hence the app crash, because it 'doesn't respond'... I'm pretty sure this is due to the multi threaded event handling as it works just fine when single threaded (there are other drawbacks, of course). The exact same crash happens when you just leave out the event handling completely. Does anyone have an idea, why Windows doesn't like my way of doing things?
Regards,
dobbi10k
-
OSes have a restriction: you must handle events in the same thread where the window was created.
-
By the way, does this restriction only concern the pollEvent() call, or also realtime inputs like sf::Mouse?
Because otherwise, it would be easy to store the events in a queue and react to them in another thread (similar to my ActionMap).
-
It's only pollEvent and waitEvent.
-
Wow, that's a relief... This means I'll only have to cahnge about 5 lines of code :)
And yeah, in that case my system is likely to work as Nexus' :)
-
OSes have a restriction: you must handle events in the same thread where the window was created.
On Mac OS X this restriction is stronger : you have to create windows and handle events in the main thread. Unfortunately.