Window message threads
Has anyone had exerpience using window message threads in a game? Is it avisable, or is there some problem with them that I don''t see?
Do you mean having a separate thread running your message loop? You could do it, but why would you want to? Your average game window won''t get many messages at all...
codeka.com - Just click it.
codeka.com - Just click it.
No, I mean using Window message threads as a means to pass information from one thread to another. Say I have one subsystem in one thread which generates events that are sent to another subsystem in another thread.
I have no idea what you mean by "window message threads".
If you have multiple threads with a message pump in each one (i.e. they call GetMessage/PeekMessage/etc) then you can use PostThreadMessage to send a message from one to another. It works fine.
There are a billion other ways to do interthread communication also.
-Mike
If you have multiple threads with a message pump in each one (i.e. they call GetMessage/PeekMessage/etc) then you can use PostThreadMessage to send a message from one to another. It works fine.
There are a billion other ways to do interthread communication also.
-Mike
Using windows message threads I take it means starting a thread that has its own separate message queue. In MFC-speak, it''s a UI thread instead of a worker thread. I can''t say whether it''s good or bad--it has its uses, and it really depends on what you''re trying to do. If messages are a comfortable way for you to do inter-thread communication, and you like the thread paradigm of using ::WaitMessage in the main loop, go for it.
The only problem with it, is that you have to wait for the OS to route the message - if that doesn''t matter it''ll work fine.
Alternatives are events and semaphores and access to the same data structures protected with critical sections. You can pass a thread a context pointer, so you can run a thread within the context of a class to give it access to data, if you want to.
Alternatives are events and semaphores and access to the same data structures protected with critical sections. You can pass a thread a context pointer, so you can run a thread within the context of a class to give it access to data, if you want to.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement