本文整理汇总了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;
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
示例6: ThreadFunc
void* ThreadFunc( void* _pParam )
{
MyThread* pMyThread = static_cast<MyThread*>( _pParam );
if( pMyThread )
int nRes = pMyThread->Run();
return pMyThread;
}
示例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();
}
示例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;
}
示例9: unlock
void unlock() {
MyThread *w = 0;
Pthread_mutex_lock(&m);
locked = 0;
w = q;
Pthread_mutex_unlock(&m);
if (w)
w->wakeup();
}
示例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);
}
示例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()));
}
}
示例12: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
MyThread mThread;
mThread.start();
mThread.wait();
qDebug() << "Done!";
return a.exec();
}
示例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
}
示例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();
}
示例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;
}