// Helper function for removing a message from the head of the queue OsStatus OsMsgQShared::doReceive(OsMsg*& rpMsg, const OsTime& rTimeout) { OsStatus ret; if (!rTimeout.isInfinite()) { int expireFromNow = rTimeout.cvtToMsecs(); if (try_dequeue(rpMsg, expireFromNow)) ret = OS_SUCCESS; else ret = OS_WAIT_TIMEOUT; } else { dequeue(rpMsg); ret = OS_SUCCESS; } system_tap_queue_dequeue(mName.data(), 0, _queue.size()); return ret; }
// Helper function for removing a message from the head of the queue OsStatus OsMsgQShared::doReceive(OsMsg*& rpMsg, const OsTime& rTimeout) { OsStatus ret; #ifdef MSGQ_IS_VALID_CHECK /* [ */ ret = mGuard.acquire(); // start critical section assert(ret == OS_SUCCESS); testMessageQ(); mNumRemoveEntry++; ret = mGuard.release(); // exit critical section assert(ret == OS_SUCCESS); #endif /* MSGQ_IS_VALID_CHECK ] */ ret = mFull.acquire(rTimeout); // wait for a message to be available if (ret != OS_SUCCESS) { if (ret == OS_BUSY || ret == OS_WAIT_TIMEOUT) ret = OS_WAIT_TIMEOUT; // receive timed out else { assert(FALSE); ret = OS_UNSPECIFIED; } } else { ret = mGuard.acquire(); // start critical section assert(ret == OS_SUCCESS); assert(numMsgs() > 0); rpMsg = (OsMsg*) mDlist.get(); // get the first message if (rpMsg == NULL) // was there a message? { assert(FALSE); ret = OS_UNSPECIFIED; } else { ret = mEmpty.release(); // the remove operation succeeded, signal assert(ret == OS_SUCCESS); // senders that there is an available // message slot. } (void)mGuard.release(); // exit critical section } #ifdef MSGQ_IS_VALID_CHECK /* [ */ OsStatus rc = mGuard.acquire(); // start critical section assert(rc == OS_SUCCESS); if (ret == OS_SUCCESS) mNumRemoveExitOk++; else mNumRemoveExitFail++; testMessageQ(); rc = mGuard.release(); // exit critical section assert(rc == OS_SUCCESS); #endif /* MSGQ_IS_VALID_CHECK ] */ system_tap_queue_dequeue(mName.data(), 0, mDlist.entries()); return ret; }