activetest.cpp
来自「这是国外的resip协议栈」· C++ 代码 · 共 90 行
CPP
90 行
#include "stdafx.h"#include "ActiveTest.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif// Construct the active testActiveTest::ActiveTest( CPPUNIT_NS::Test *test ) : TestDecorator( test ) , m_runCompleted() { m_currentTestResult = NULL; m_threadHandle = INVALID_HANDLE_VALUE; }// Pend until the test has completedActiveTest::~ActiveTest(){ CSingleLock( &m_runCompleted, TRUE ); m_test = NULL;}// Set the test result that we are to runvoid ActiveTest::setTestResult( CPPUNIT_NS::TestResult *result ){ m_currentTestResult = result; }// Run our test resultvoid ActiveTest::run(){ TestDecorator::run( m_currentTestResult );}// Spawn a thread to a testvoid ActiveTest::run( CPPUNIT_NS::TestResult *result ){ CWinThread *thread; setTestResult( result ); m_runCompleted.ResetEvent(); thread = ::AfxBeginThread( threadFunction, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); ::DuplicateHandle( GetCurrentProcess(), thread->m_hThread, GetCurrentProcess(), &m_threadHandle, 0, FALSE, DUPLICATE_SAME_ACCESS ); thread->ResumeThread ();}// Simple execution thread. Assuming that an ActiveTest instance// only creates one of these at a time.UINT ActiveTest::threadFunction( LPVOID thisInstance ){ ActiveTest *test = (ActiveTest *)thisInstance; test->run (); ::CloseHandle( test->m_threadHandle ); test->m_threadHandle = INVALID_HANDLE_VALUE; test->m_runCompleted.SetEvent(); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?