本文整理汇总了C++中Producer::start方法的典型用法代码示例。如果您正苦于以下问题:C++ Producer::start方法的具体用法?C++ Producer::start怎么用?C++ Producer::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Producer
的用法示例。
在下文中一共展示了Producer::start方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: producerConsumer
void tst_QSemaphore::producerConsumer()
{
Producer producer;
Consumer consumer;
producer.start();
consumer.start();
producer.wait();
consumer.wait();
}
示例2: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
Producer producer;
producer.registerCallBack(callBackFunction);
producer.start();
producer.wait();
}
示例3: main
int main()
{
usedSpace += BufferSize;
Producer producer;
Consumer consumer;
producer.start();
consumer.start();
producer.wait();
consumer.wait();
return 0;
}
示例4: main
//! [5]
int main(int argc, char *argv[])
//! [5] //! [6]
{
QCoreApplication app(argc, argv);
Producer producer;
Consumer consumer;
producer.start();
consumer.start();
producer.wait();
consumer.wait();
return 0;
}
示例5: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Producer producer;
Consumer consumer;
producer.start();
consumer.start();
producer.wait();
consumer.wait();
return a.exec();
}
示例6: main
int main(int argc, char *argv[])
{
//QApplication app(argc, argv);
//Window *w = new Window;
//w->resize(300, 300);
//w->show();
//return app.exec();
QApplication app(argc, argv);
Producer produer;
Consumer consumer;
produer.start();
consumer.start();
produer.wait();
consumer.wait();
return app.exec();
}
示例7: main
int main() {
ProducerConsumerMonitor monitor;
Producer producer = Producer(&monitor);
producer.start();
Consumer consumer = Consumer(&monitor);
consumer.start();
Consumer anotherConsumer = Consumer(&monitor);
anotherConsumer.start();
producer.waitFor();
consumer.waitFor();
anotherConsumer.waitFor();
}
示例8: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
initaldatabase();//初始化数据库
QSqlDatabase::removeDatabase("first");
Producer producer;
producer.start();
SqlwriteThread_buffer *threadvector[THREADNUM];
for(int i=0; i< THREADNUM; ++i)
{
threadvector[i] = new SqlwriteThread_buffer("localhost","whztest","root","infonet313",i);
// threadvector[i]->SetRange(1024*10);
}
QTime t;
t.start();
for(int i=0; i< THREADNUM; ++i)
{
threadvector[i]->start();
}
QTime blankspace;
blankspace.start();
for(int i=0; i< THREADNUM; ++i)
{
qDebug()<<QObject::trUtf8("第 %1 个线程和第 %2 个线程之间等待耗时:%3 ms").arg(i).arg(i+1).arg(blankspace.elapsed());
threadvector[i]->wait();
blankspace.restart();
}
producer.wait();
qDebug()<<QObject::trUtf8("插入 %1 条记录,耗时:%2 ms").arg(1024*100).arg(t.elapsed());
exit(0);
return a.exec();
}
示例9: if
int
main(int argc, char** argv)
{
// char consumer_reg[100];
int i=0;
int flag_prod=0;
int flag_cons=0;
int check_flag=0;
for(i=0;i<argc;i++)
{
if((strcmp(argv[i],"-p")==0))
check_flag++;
if((strcmp(argv[i],"-d")==0))
check_flag++;
}
if(check_flag==1){
for(i=1;i<argc;i++)
{
if((strcmp(argv[i],"-p")==0))
{
printf("In Producer\n");
i=i+1;
flag_prod=1;
break;
}
if((strcmp(argv[i],"-d")==0))
{
printf("In Consumer\n");
i=i+1;
flag_cons=1;
break;
}
}
if(flag_prod==1)
{
int j=0;
number_of_prod_files=argc-i;
for(j=0;j<number_of_prod_files;j++)
{
strcpy(producer_reg[j],argv[i]);
++i;
}
printf("Files in the Producer are as below\n");
for(j=0;j<number_of_prod_files;j++)
{
printf("%s\n",producer_reg[j]);
}
Producer p;
p.start();
flag_prod=0;
}
else if(flag_cons==1)
{
int j=0;
char string_to_send[800];
number_of_cons_files=argc-i;
for(j=0;j<number_of_cons_files;j++)
{
memset(&string_to_send,0,sizeof(string_to_send));
strcat(string_to_send,argv[i]);
strcat(string_to_send,"/$");
strcpy(consumer_reg[j],string_to_send);
++i;
}
printf("Files in the Consumer are as below\n");
for(j=0;j<number_of_cons_files;j++)
{
printf("%s\n",consumer_reg[j]);
}
Consumer c;
c.start_c();
flag_cons=0;
}
}
else if(check_flag==2)
{
int p_index=0;
int d_index=0;
for(i=1;i<argc;i++)
{
if((strcmp(argv[i],"-p")==0))
p_index=i;
if((strcmp(argv[i],"-d")==0))
d_index=i;
if(p_index!=0 && d_index!=0)
break;
}
if(p_index<d_index && p_index!=0)
{
i=0;
int j=0;
for(j=p_index+1;j<d_index;j++)
{
strcpy(producer_reg[i],argv[j]);
++i;
}
number_of_prod_files=i;
//.........这里部分代码省略.........
示例10: test
static void test()
{
Producer thread;
thread.start();
}