当前位置: 首页>>代码示例>>C++>>正文


C++ MyThread类代码示例

本文整理汇总了C++中MyThread的典型用法代码示例。如果您正苦于以下问题:C++ MyThread类的具体用法?C++ MyThread怎么用?C++ MyThread使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MyThread类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testThreadInitAndExit

void testThreadInitAndExit()
{
    std::cout<<"******   Running thread start and delete test   ****** "<<std::endl;

    {
        MyThread thread;
        thread.startThread();
    }
    
    // add a sleep to allow the thread start to fall over it its going to.
    OpenThreads::Thread::microSleep(500000);
    
    std::cout<<"pass    thread start and delete test"<<std::endl<<std::endl;


    std::cout<<"******   Running notify thread test   ****** "<<std::endl;

    {
        NotifyThread thread1(osg::INFO,"thread one:");
        NotifyThread thread2(osg::INFO,"thread two:");
        NotifyThread thread3(osg::INFO,"thread three:");
        NotifyThread thread4(osg::INFO,"thread four:");
        thread1.startThread();
        thread2.startThread();
        thread3.startThread();
        thread4.startThread();

        // add a sleep to allow the thread start to fall over it its going to.
        OpenThreads::Thread::microSleep(5000000);
    }

    std::cout<<"pass    noitfy thread test."<<std::endl<<std::endl;
}
开发者ID:joevandyk,项目名称:osg,代码行数:33,代码来源:osgunittests.cpp

示例2: the_thread

void* MyThread::the_thread(void * param)
{
    MyThread *thread;
    void *ret;

    thread = (MyThread*)param;

    thread->continue_mtx2_.lock();

    thread->mutex_.lock();
    thread->running_ = true;
    thread->mutex_.unlock();

    thread->continue_mtx_.lock();
    thread->continue_mtx_.unlock();

    ret = thread->thread();

    thread->mutex_.lock();
    thread->running_ = false;
    thread->retval_ = ret;
    thread->mutex_.unlock();

    return NULL;
}
开发者ID:abo321,项目名称:mythreadlib,代码行数:25,代码来源:mythread.cpp

示例3: qDebug

void MyServer::incomingConnection(int socketDescriptor)
{
    qDebug() << socketDescriptor << " Connecting...";
    MyThread *thread = new MyThread(socketDescriptor,this);
    connect(thread, SIGNAL(finished()),thread, SLOT(deleteLater()));
    thread->start();
}
开发者ID:thomasalvatran,项目名称:June2015,代码行数:7,代码来源:myserver.cpp

示例4: Thread

extern "C" void *
Thread(void *arg)
{
	MyThread *me = (MyThread *)arg;
	int n;
	unsigned int t, s = (int)arg;
	char b[100];
	time_t t1, t2;

	me->print("start");
	for (n = 1; ;++n) {
		t = rand_r(&s) % 4;

		t1 = time(NULL);
		fl.lock(me);
		t2 = time(NULL);
		sprintf(b, "lock %03d at %d, start wait at %d", n, t2, t1);
		me->print(b);
		if (t)
			sleep(t);
		fl.unlock();

		t = rand_r(&s) % 4;
		if (t)
			sleep(t);
	}

	return 0;
}
开发者ID:jyting,项目名称:CPagerank,代码行数:29,代码来源:fairlock.C

示例5: qDebug

void MyServer::incomingConnection(qintptr socketDescriptor){

  qDebug() << socketDescriptor << " connecting...";
  MyThread *thread = new MyThread(socketDescriptor,this, &storage);
  connect(thread,SIGNAL(finished()), thread, SLOT(deleteLater()));
  thread->run();
}
开发者ID:rianmartins,项目名称:DCA0102-FinalProject,代码行数:7,代码来源:myserver.cpp

示例6: ThreadFunc

void* ThreadFunc( void* _pParam )
{
	MyThread* pMyThread = static_cast<MyThread*>( _pParam );

	if( pMyThread )
		int nRes = pMyThread->Run();

	return pMyThread;
}
开发者ID:hukka-mail-ru,项目名称:hukka,代码行数:9,代码来源:mythread.cpp

示例7: QTimer

void MyObject::start()
{
    QTimer *timer = new QTimer(this);
    timer->setInterval(1000);
    connect(timer, SIGNAL(timeout()), SLOT(DoSomething()));
    MyThread *t = new MyThread(this);
    connect(t, SIGNAL(finished()), SLOT(onFinished()));
    connect(t, SIGNAL(finished()), timer, SLOT(start()));
    t->start();
}
开发者ID:Amartel1986,项目名称:test,代码行数:10,代码来源:MyObject.cpp

示例8: while

int TcpServThr::WaitAllThr()
{
   vector<MyThread*>::iterator it = ThrSet->begin();
   while (it != ThrSet->end()) {
      MyThread* thr = (MyThread*)(*it);
      pthread_join(thr->getId(),NULL);
      it++;
      }
   return 0;
}
开发者ID:anjsxz,项目名称:ctest,代码行数:10,代码来源:TcpServThr.cpp

示例9: unlock

	void unlock() {
		MyThread *w = 0;

		Pthread_mutex_lock(&m);
		locked = 0;
		w = q;
		Pthread_mutex_unlock(&m);

		if (w)
			w->wakeup();
	}
开发者ID:jyting,项目名称:CPagerank,代码行数:11,代码来源:fairlock.C

示例10: TEST

TEST( Thread, freeOnTerminateTest )
{
  static const int COUNT = 5;
  for (int i = 0; i < COUNT; i++)
  {
    MyThread* myThread = new MyThread(i);
    myThread->freeOnTerminate = true;
    EXPECT_TRUE( myThread->open() );
  }
  sleep(1);
}
开发者ID:idkwim,项目名称:vdream90,代码行数:11,代码来源:threadtest.cpp

示例11: WXUNUSED

void MyFrame::evhSendMsg( wxCommandEvent& WXUNUSED(event) ) {
	long victim = m_listCtrl1->GetSelected();
	if (victim != -1){
		MyThread *pThr = vciMailingList[m_listCtrl1->GetItemData(victim)];
		unsigned long TID = pThr->getID();
		wxMutexLocker ml(vciMailingList[TID]->mtxMail);
		vciMailingList[TID]->semMail.Post();
		vciMailingList[TID]->lstMail.push_back(new wxString(wxT("SYSTEM;")+m_textCtrl2->GetValue()));
	}

}
开发者ID:SiTLar,项目名称:tireless-worker,代码行数:11,代码来源:main.cpp

示例12: main

int main(int argc, char *argv[])
{
	QCoreApplication a(argc, argv);

	MyThread mThread;
	mThread.start();

	mThread.wait();
	qDebug() << "Done!";

	return a.exec();
}
开发者ID:ggurbet,项目名称:qtexamples,代码行数:12,代码来源:main.cpp

示例13: WXUNUSED

void MyFrame::OnStartThread(wxCommandEvent& WXUNUSED(event) )
{
    MyThread *thread = CreateThread();

    if ( thread->Run() != wxTHREAD_NO_ERROR )
    {
        wxLogError(wxT("Can't start thread!"));
    }

#if wxUSE_STATUSBAR
    SetStatusText(wxT("New thread started."), 1);
#endif // wxUSE_STATUSBAR
}
开发者ID:ruifig,项目名称:nutcracker,代码行数:13,代码来源:thread.cpp

示例14: QMainWindow

SexWindow::SexWindow(QWidget *parent) 
    : QMainWindow(parent)
    , ui(new Ui_MainWindow)
{
    ui->setupUi(this);
    MyThread *mythread = new MyThread;
    
    /** 元类型的注册方法 **/
    int id = qRegisterMetaType<PEOPLE>("PEOPLE");
    
    connect(mythread, SIGNAL(changeText(PEOPLE)), this, 
            SLOT(labelSetText(PEOPLE)),Qt::QueuedConnection);  
    mythread->start();  
}
开发者ID:halukasama,项目名称:learnQt,代码行数:14,代码来源:3sexwindow.cpp

示例15: enter

MyThread *MyFrame::CreateThread()
{
    MyThread *thread = new MyThread;

    if ( thread->Create() != wxTHREAD_NO_ERROR )
    {
        wxLogError(wxT("Can't create thread!"));
    }

    wxCriticalSectionLocker enter(wxGetApp().m_critsect);
    wxGetApp().m_threads.Add(thread);

    return thread;
}
开发者ID:ruifig,项目名称:nutcracker,代码行数:14,代码来源:thread.cpp


注:本文中的MyThread类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。