Can I wait for windows events (WaitForMultipleObjects) in a QP (Quantum Platform) active object?

StackOverflow https://stackoverflow.com/questions/12481835

  •  02-07-2021
  •  | 
  •  

Question

in my current code I wait for some event to occur using something like

WaitForMultipleObjects(2,pEvents,false,1000);

in s separate thread and post stuff to a State Machine whenever I get events worth posting. I am porting this behavior into QP where, as I understand it, each active object is its own thread. Can I therefore just do this in an infinite loop (with some terminate break condition) in an Active object?

As I understand it QP is waiting on a windows event under the hood as well, is there a trick to retrieve a handle to the windows event representing my current active objects queue and wait on it as well so my thread (active object) blocks on my (non QP) events AND the event activated if some other object posts to my queue?

Was it helpful?

Solution

In case anyone is interested I found just what I was looking for. The member m_osObject of QActive is a handle to the event waited on when the input queue is empty.

Note that I only tested this on the windows port of QP and to the best of my knowledge it does not work with any other port.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top