pend 方法會封鎖建立呼叫的作業,直到佇列中有訊息為止。一般而言,讀取器會一直等待,直到佇列包含其可以讀取的訊息為止。
簽章RiCOSResult RiCOSMessageQueue_pend(
RiCOSMessageQueue *const me);
傳回RiCOSResult 物件,如 RiCOS*.h 檔案所定義
範例RiCOSResult RiCOSMessageQueue_pend(
RiCOSMessageQueue * const me)
{
if (me == NULL) return 0;
if (me->m_State == noData) {
gen_ptr m = NULL;
if (msgQReceive(me->hVxMQ, (char*)&m, sizeof(m),
NO_WAIT) <= 0) /* if the queue is empty *
(void)msgQReceive(me->hVxMQ, (char*)&m,
sizeof(m), WAIT_FOREVER); /* wait for message */
me->m_State = dataReady;
me->pmessage = m;
}
return 1;}