本文整理汇总了C++中boost::condition_variable_any::notify_all方法的典型用法代码示例。如果您正苦于以下问题:C++ condition_variable_any::notify_all方法的具体用法?C++ condition_variable_any::notify_all怎么用?C++ condition_variable_any::notify_all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::condition_variable_any
的用法示例。
在下文中一共展示了condition_variable_any::notify_all方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: myUserHandler15
void myUserHandler15( const CanMsgStruct/*&*/ message) {
_canmodule_slowDown( 15 );
boost::unique_lock<boost::mutex> lock{reception_mtx15};
_connection_v[ 15 ].reception.newArrived = true;
_connection_v[ 15 ].reception.receivedMessageBuffer = message;
reception_cond15.notify_all();
}
示例2: process
void my_search::process(int proc_num){
vector<int> cur_ch;
vector<int> words;
int i=0,word_size;
while(argv[proc_num+1][i]!=0)i++;
word_size=i;
words.resize(argc-4);
cur_ch.resize(argc-4);
while(counter_file<max_file){
boost::lock_guard<boost::mutex> lock(m);
while((counter==0)||(thr[proc_num]==false)){
if(counter_file>=max_file)return;
cv.wait(m);
}
pantheios::log_NOTICE(PSTR("Reading thread id: ["), pantheios::threadId, PSTR("]"));
for(unsigned int c=0;c<memblock.size();c++){
char i=memblock[c];
if(argv[proc_num+1][cur_ch[file_num]]==i)
cur_ch[file_num]++;
else cur_ch[file_num]=0;
if(cur_ch[file_num]==word_size){
words[file_num]++;sum++;cur_ch[file_num]=0;
}
}
counter--;
thr[proc_num]=false;
if(comp_size[file_num]==0){
cout<<argv[file_num+4]<<" "<<argv[proc_num+1]<<
" "<<words[file_num]<<endl;
counter_file++;
}
cv.notify_all();
}
return;
}
示例3: myUserHandler0
/**
* The user-handlerX gets invoked each time there is a new can message on connectionX, according to HW sync.
* We put this message into a buffer, protect it from the wait, and notify the wait that
* the new msg can be picked up. Using boost for sync.
*
* this handler must be connected to the CanModule access point by this wrapper in the canmodule_init call,
* and this is hardcoded. We can have only static mutexes and cond_vars, therefore we have to decide BEFORE
* compile-time how many reception threads we want. While in principle we can have a big number easily, let's
* limit the number of connections ( PC port or ip-number && CAN port ) we can have PER TASK to 16.
* This corresponds to 16 CAN buses, using i.e. one systec16 module or 8 anagate-duos.
*
* The user can conveniently pick up the new message from the waitForNewMessage call which
* blocks until new reception. Just a separate thread or whatever sequence is needed for the
* blocking reception call, the user can implement whatever scheme she likes.
*/
void myUserHandler0( const CanMsgStruct/*&*/ message) {
int connectionIndex = 0;
LOG(Log::TRC) << __FUNCTION__ << " received a message [id= " << message.c_id << " data0= " << (int) message.c_data[ 0 ]
<< "] connectionIndex= " << connectionIndex;
_canmodule_slowDown( connectionIndex );
{
boost::unique_lock<boost::mutex> lock{reception_mtx0};
_connection_v[ connectionIndex ].reception.newArrived = true;
_connection_v[ connectionIndex ].reception.receivedMessageBuffer = message;
}
LOG(Log::TRC) << __FUNCTION__ << " new message copied, notify_all connectionIndex= " << connectionIndex;
reception_cond0.notify_all();
}
示例4: loadfile
void my_search:: loadfile(int fl_num){
file[fl_num].open(argv[fl_num+4], ios::in|ios::binary|ios::ate);
if (file[fl_num].is_open())
{
comp_size[fl_num] = file[fl_num].tellg();
file[fl_num].seekg (0, ios::beg);
while(comp_size[fl_num]>0){
boost::lock_guard<boost::mutex> lock(m);
while(counter!=0){
cv.wait(m);
}
pantheios::log_NOTICE(PSTR("Writing thread id: ["), pantheios::threadId, PSTR("]"));
if(comp_size[fl_num]<1024){
file[fl_num].read (mem, comp_size[fl_num]);
memblock=mem;
memblock.resize(comp_size[fl_num]);
comp_size[fl_num]=0;
}else {
file[fl_num].read (mem, 1024);
memblock=mem;
memblock.resize(1024);
comp_size[fl_num]-=1024;
}
counter=3;
file_num=fl_num;
for (int cc=0;cc<3;cc++)thr[cc]=true;
cv.notify_all();
}
file[fl_num].close();
}else {
boost::lock_guard<boost::mutex> lock(m);
cout << "Unable to open file "<<argv[fl_num+4]<<endl;
counter_file+=3;
cv.notify_all();
}
return;
}