pend 方法用于阻塞执行调用的任务,直到队列中出现消息为止。阅读器通常等待,直到队列中包含它可以读取的消息为止。
RiCOSResult RiCOSMessageQueue_pend(
RiCOSMessageQueue *const me);
me
这是 RiCOSMessageQueue
RiCOS*.h 文件中定义的 RiCOSResult 对象
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;}