31 lines
727 B
Plaintext
31 lines
727 B
Plaintext
#include <thread/thread.hpp>
|
|
|
|
WORD PureThread::start(LPVOID lpCreationData)
|
|
{
|
|
if(isOkay()||!mlpfnThreadProc)return FALSE;
|
|
mhThread=::CreateThread((SECURITY_ATTRIBUTES*)0,InitialStack,mlpfnThreadProc,lpCreationData,CREATE_SUSPENDED,&mThreadID);
|
|
if(!mhThread)return FALSE;
|
|
mThreadStatus=InSuspend;
|
|
return TRUE;
|
|
}
|
|
|
|
WORD PureThread::fatalThreadExit(void)
|
|
{
|
|
WORD returnCode(FALSE);
|
|
|
|
if(!isOkay())return returnCode;
|
|
returnCode=::TerminateThread(mhThread,exitCode());
|
|
mThreadStatus=InStop;mhThread=0;mThreadID=0;
|
|
return returnCode;
|
|
}
|
|
|
|
DWORD PureThread::exitCode(void)const
|
|
{
|
|
DWORD exitCodeThread(0L);
|
|
|
|
if(!isOkay())return exitCodeThread;
|
|
::GetExitCodeThread(mhThread,&exitCodeThread);
|
|
return exitCodeThread;
|
|
}
|
|
|