2012-07-27 263 views

回答

2

没有内置API来刷新消息队列中的所有消息。
如果你想要做的是从队列中丢弃的所有消息,这里是一个快速的方法来做到这一点:

void discardQMessages(MSG_Q_ID id) { 
    while(
     msgQReceive(id, NULL, 0, NO_WAIT) != ERROR 
     ) ; 

    if {errno != S_objLib_OBJ_UNAVAILABLE) 
    /* Uh oh... got some problem */ 
} 

那么当您从任何OS API调用收到错误总是检查errno。

+0

thnx您的信息。我也只是以这种方式思考。 – Pratik 2012-07-30 03:03:50