本文整理汇总了C++中MyThread::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ MyThread::Create方法的具体用法?C++ MyThread::Create怎么用?C++ MyThread::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyThread
的用法示例。
在下文中一共展示了MyThread::Create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: CreateThread
bool MyFrame::CreateThread(MyFrame *m_frame, const wxString&sFPath, unsigned long &TID){
wxString sScript;
if (!LoadScript(sFPath, sScript) )return false;
wxString sFName = wxFileName(sFPath).GetFullName();
MyThread *thread = new MyThread(m_frame, sScript, sFName, sFPath);
if ( thread->Create() != wxTHREAD_NO_ERROR ){
wxLogError(wxT("Can't create thread!"));
return false;
}
TID = vciMailingList.insert(thread);
thread->setID(TID);
m_listCtrl1->AddItem(sFName, TID);
return true;
}
示例3: TestWithThreads
void AtomicTestCase::TestWithThreads(int count, ETestType testType)
{
wxAtomicInt int1=0;
wxArrayThread threads;
int i;
for ( i = 0; i < count; ++i )
{
ETestType actualThreadType;
switch(testType)
{
default:
actualThreadType = testType;
break;
case IncOnly:
actualThreadType = (i&1)==0 ? IncOnly : DecOnly;
break;
}
MyThread *thread = new MyThread(int1, actualThreadType);
if ( thread->Create() != wxTHREAD_NO_ERROR )
{
wxLogError(wxT("Can't create thread!"));
}
else
threads.Add(thread);
}
for ( i = 0; i < count; ++i )
{
threads[i]->Run();
}
for ( i = 0; i < count; ++i )
{
// each thread should return 0, else it detected some problem
CPPUNIT_ASSERT (threads[i]->Wait() == (wxThread::ExitCode)0);
}
CPPUNIT_ASSERT( int1 == 0 );
}
示例4: TestReceive
// this function creates the given number of threads and posts msgCount
// messages to the last created thread which, in turn, posts all the messages
// it receives to the previously created thread which does the same and so on
// in cascade -- at the end, each thread will have received all msgCount
// messages directly or indirectly
void QueueTestCase::TestReceive()
{
const int msgCount = 100;
const int threadCount = 10;
ArrayThread threads;
int i;
for ( i = 0; i < threadCount; ++i )
{
MyThread *previousThread = i == 0 ? NULL : threads[i-1];
MyThread *thread =
new MyThread(WaitInfinitlyLong, previousThread, msgCount);
CPPUNIT_ASSERT_EQUAL ( thread->Create(), wxTHREAD_NO_ERROR );
threads.Add(thread);
}
for ( i = 0; i < threadCount; ++i )
{
threads[i]->Run();
}
MyThread* lastThread = threads[threadCount - 1];
for ( i = 0; i < msgCount; ++i )
{
lastThread->GetQueue().Post(i);
}
for ( i = 0; i < threadCount; ++i )
{
// each thread should return the number of messages received.
// if it returns a negative, then it detected some problem.
wxThread::ExitCode code = threads[i]->Wait();
CPPUNIT_ASSERT_EQUAL( code, (wxThread::ExitCode)wxMSGQUEUE_NO_ERROR );
}
}