一個利用條件變量寫的消息隊列,基於雙緩沖的,雖然相比三緩沖的差距不小,但是還是值得拿來學習一下條件變量。
BUFQUEUE_H_<list><pthread.h> * BATPROCESS_NUM 5 ~ peek(CommonItem &<CommonItem>* serial_read(std::list<CommonItem>* WaitReadEventByTimeOut(&<CommonItem>*<CommonItem>* /* BUFQUEUE_H_ */
<sys/time.h><time.h> maketimeout( timespec* tsp, ns = gettimeofday(&now,->tv_sec =->tv_nsec = now.tv_usec * ; tsp->tv_nsec += *<CommonItem>*(pList ==(pList->= pList->->&->&->&->->_read_list = std::list<CommonItem>->_write_list = std::list<CommonItem>~&->&->&->->_read_list->->_write_list-> BufQueue::peek(CommonItem &&->= PopMsgToPutFromList(->&-> (item == issetread = &->->_write_list->= (->_write_list->size() >&->-> <CommonItem>* BufQueue::serial_read(std::list<CommonItem>*&-><CommonItem>* tmplist = ->->_write_list = ->->_read_list == ->->_read_list =&->&->&->&-> BufQueue::WaitReadEventByTimeOut(&&->&ts,= ( == pthread_cond_timedwait(&->_read_cond,&->_read_mutex, &&->
給出測試代碼和用法
* process(* i=( *j = *j = *++ main( argc,*&pid,,process, start =(< *>* queue_to_read = list< *> read = =< *>(iter = queue_to_read->begin();iter != queue_to_read->end();iter ++* j = (*)(*( <= (* end =,(end - ,(*
有興趣的可以測試下,有什麼問題可以聯系我!