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


C++ MyThread::Create方法代码示例

本文整理汇总了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;
}
开发者ID:ruifig,项目名称:nutcracker,代码行数:14,代码来源:thread.cpp

示例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;
}
开发者ID:SiTLar,项目名称:tireless-worker,代码行数:16,代码来源:main.cpp

示例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 );
}
开发者ID:CustomCardsOnline,项目名称:wxWidgets,代码行数:44,代码来源:atomic.cpp

示例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 );
    }
}
开发者ID:euler0,项目名称:Helium,代码行数:43,代码来源:queue.cpp


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