初步修复
This commit is contained in:
parent
8fc4357cc6
commit
e4714f3f0e
46705 changed files with 12004901 additions and 0 deletions
61
Client/EtFileSystemTool/Thread.cpp
Normal file
61
Client/EtFileSystemTool/Thread.cpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#include "stdafx.h"
|
||||
#include "Thread.h"
|
||||
|
||||
|
||||
Thread::Thread()
|
||||
: m_nThreadID( 0 ), m_hHandleThread( INVALID_HANDLE_VALUE )
|
||||
{
|
||||
}
|
||||
|
||||
Thread::~Thread()
|
||||
{
|
||||
m_bThreadLoop = false;
|
||||
}
|
||||
|
||||
bool
|
||||
Thread::Start()
|
||||
{
|
||||
if( m_hHandleThread != INVALID_HANDLE_VALUE )
|
||||
return false;
|
||||
|
||||
m_hHandleThread = ::CreateThread( 0, 0, _Runner, ( LPVOID )this, 0, &m_nThreadID );
|
||||
if( m_hHandleThread == 0 )
|
||||
return false;
|
||||
|
||||
m_bThreadLoop = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Thread::Terminate( DWORD nExitCode )
|
||||
{
|
||||
bool ret;
|
||||
|
||||
if( m_hHandleThread == INVALID_HANDLE_VALUE )
|
||||
return true;
|
||||
|
||||
ret = ( ::TerminateThread( m_hHandleThread, nExitCode ) == TRUE );
|
||||
m_hHandleThread = INVALID_HANDLE_VALUE;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
Thread::WaitForTerminate( DWORD nTimeout )
|
||||
{
|
||||
if( m_hHandleThread == INVALID_HANDLE_VALUE )
|
||||
return false;
|
||||
|
||||
return ( ::WaitForSingleObject( m_hHandleThread, nTimeout ) == WAIT_OBJECT_0 );
|
||||
}
|
||||
|
||||
DWORD WINAPI
|
||||
Thread::_Runner( LPVOID pParam )
|
||||
{
|
||||
Thread* pInstance = static_cast<Thread*>( pParam );
|
||||
|
||||
pInstance->Run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue