// Processes all of the messages currently queued for this flow graph. // For now, this method always returns OS_SUCCESS. OsStatus MpFlowGraphBase::processMessages(void) { OsWriteLock lock(mRWMutex); UtlBoolean done; UtlBoolean handled; static MpFlowGraphMsg* pStopMsg = NULL; MpResource* pMsgDest; OsStatus res; // First, we send ourselves a FLOWGRAPH_PROCESS_FRAME message. // This message serves as a "stopper" in the message queue. When we // handle that message, we know that we have processed all of the messages // for the flowgraph (and its resources) that had arrived prior to the // start of this frame processing interval. if (NULL == pStopMsg) { pStopMsg = new MpFlowGraphMsg(MpFlowGraphMsg::FLOWGRAPH_PROCESS_FRAME); pStopMsg->setReusable(TRUE); } res = postMessage(*pStopMsg); assert(res == OS_SUCCESS); done = FALSE; while (!done) { // get the next message OsMsg* pMsg ; res = mMessages.receive(pMsg, OsTime::NO_WAIT); assert(res == OS_SUCCESS); if (pMsg->getMsgType() == OsMsg::MP_FLOWGRAPH_MSG) { MpFlowGraphMsg* pRcvdMsg = (MpFlowGraphMsg*) pMsg ; // determine if this message is intended for a resource in the // flow graph (as opposed to a message for the flow graph itself) pMsgDest = pRcvdMsg->getMsgDest(); if (pMsgDest != NULL) { // deliver the message if the resource is still part of this graph if (pMsgDest->getFlowGraph() == this) { handled = pMsgDest->handleMessage(*pRcvdMsg); assert(handled); } } else { // since pMsgDest is NULL, this msg is intended for the flow graph switch (pRcvdMsg->getMsg()) { case MpFlowGraphMsg::FLOWGRAPH_PROCESS_FRAME: done = TRUE; // "stopper" message encountered -- we are done break; // processing messages for this frame interval default: handled = handleMessage(*pRcvdMsg); assert(handled); break; } } pRcvdMsg->releaseMsg(); // free the msg } else { handled = handleMessage(*pMsg); assert(handled); pMsg->releaseMsg() ; } } return OS_SUCCESS; }