本文整理汇总了C++中boost::condition_variable_any::wait方法的典型用法代码示例。如果您正苦于以下问题:C++ condition_variable_any::wait方法的具体用法?C++ condition_variable_any::wait怎么用?C++ condition_variable_any::wait使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::condition_variable_any
的用法示例。
在下文中一共展示了condition_variable_any::wait方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
{
L1 lk(m0);
boost::thread t(f);
BOOST_TEST(test1 == 0);
while (test1 == 0)
cv.wait(lk);
BOOST_TEST(test1 != 0);
test2 = 1;
lk.unlock();
cv.notify_one();
t.join();
}
test1 = 0;
test2 = 0;
{
L1 lk(m0);
boost::thread t(f);
BOOST_TEST(test1 == 0);
while (test1 == 0)
cv.wait(lk);
BOOST_TEST(test1 != 0);
lk.unlock();
t.join();
}
return boost::report_errors();
}
示例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: wait
count_type wait()
{
all_futures_lock lk(waiters_);
for (;;)
{
for (count_type i = 0; i < waiters_.size(); ++i)
{
if (waiters_[i].future_->is_ready(lk.locks[i]))
{
return waiters_[i].index;
}
}
cv.wait(lk);
}
}
示例4: put
void put(int x)
{
{
boost::mutex::scoped_lock lock(mu);
while (is_full())
{
{
boost::mutex::scoped_lock lock(io_mu);
cout << "full waiting..." << endl;
}
cond_put.wait(mu);
}
stk.push(x);
++un_read;
}
cond_get.notify_one();
}
示例5: get
void get(int *x)
{
{
boost::mutex::scoped_lock lock(mu);
while (is_empty())
{
{
boost::mutex::scoped_lock lock(io_mu);
cout << "empty waiting..." << endl;
}
cond_get.wait(mu);
}
--un_read;
*x = stk.top();
stk.pop();
}
cond_put.notify_one();
}
示例6: 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;
}