Initial
This commit is contained in:
41
thread/THREAD.CPP
Normal file
41
thread/THREAD.CPP
Normal file
@@ -0,0 +1,41 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
PureThread::ThreadPriority PureThread::getThreadPriority(void)const
|
||||
{
|
||||
if(!isOkay())return ThreadPriorityNormal;
|
||||
return ThreadPriority(::GetThreadPriority(mhThread));
|
||||
}
|
||||
|
||||
PureThread::ThreadPriority PureThread::setThreadPriority(ThreadPriority threadPriority)const
|
||||
{
|
||||
if(!isOkay())return ThreadPriorityNormal;
|
||||
return ThreadPriority(::SetThreadPriority(mhThread,(int)threadPriority));
|
||||
}
|
||||
Reference in New Issue
Block a user