本文整理汇总了C++中queue::check_entire方法的典型用法代码示例。如果您正苦于以下问题:C++ queue::check_entire方法的具体用法?C++ queue::check_entire怎么用?C++ queue::check_entire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类queue
的用法示例。
在下文中一共展示了queue::check_entire方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
tools.enqueue(random_tool1);
cout<<"get tools"<<random_tool1<<" by operator "<<tid<<endl;
tools.show();
}
else if (tools.size()==1)
{
random_tool1=rand() % tool_num + 1;
if (!(random_tool1==random_tool2))
{
tools.enqueue(random_tool1);
cout<<"get tools"<<random_tool1<<" by operator "<<tid<<endl;
tools.show();
}
}
}
}
int product=require.dequeue();
product=product+require.dequeue();
output_Q.enqueue(product);
cout<<"output_Q: "<<endl;
output_Q.show();
if (product==3)
product1_count++;
else if (product==4)
product2_count++;
else
product3_count++;
cout<<product1_count<<" of product 3 are generated\n";
cout<<product2_count<<" of product 4 are generated\n";
cout<<product3_count<<" of product 5 are generated\n";
}
else// if it is not 1st product
{
if ((!output_Q.recent(check_product)) || (!output_Q.check_entire(check_product)))
{
dead_count++;
cout<<"Deadlock due to recent product is same as new product or different number of products are more than 10 !!!"<<endl;
cout<<"Number of deadlock happened is "<<dead_count<<endl;
while(fix_buffer.size() >=10) //check if there are many of those products
if (pthread_cond_wait (&C1, &M))//producer of the material goes to wait
{
fprintf (stdout, "pthread_cond_wait: producer\n");
exit (-1);
}
//for (int i=0;i<2;i++)
//{
int put_back=require.dequeue();
fix_buffer.enqueue(put_back);
pthread_cond_signal (&C1);
cout<<"Prevent Deadlock put : "<<put_back<<" to buffer"<<endl;
fix_buffer.show();
cout<<"current size of fix_buffer is "<<fix_buffer.size()<<endl;
//}
}
/*while(!output_Q.recent(product))//if recent is of same kind then wait
if (pthread_cond_wait (&C2, &M))
{
fprintf (stdout, "pthread_cond_wait: consumer\n");
exit (-1);
}
while(!output_Q.check_entire(product))// wait if the difference are 10
if (pthread_cond_wait (&C2, &M))
{
fprintf (stdout, "pthread_cond_wait: consumer\n");