⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmthread.cpp

📁 Soul的源代码,类似于劲舞团之类的游戏
💻 CPP
字号:
#include <windows.h>
#include "CMThread.h"
#include "CMThreadManager.h"

using namespace MatrixCore::System;

CMThread::CMThread()
	: isStarted( false ) ,m_StartRoutine(NULL)
{
}

CMThread::~CMThread()
{
	CMThreadManager::releaseInstance();
}

void CMThread::InitWork(LPTHREAD_START_ROUTINE  StartRoutine)
{
}

void CMThread::begin(LPVOID parameter)
{
	if( isStarted == true )
		return;

	if( NULL == m_StartRoutine )
	{
		if(parameter != NULL)
            handleThread = CMThreadManager::getInstance()->spawn( CMThread::handleRunner, parameter, &thredID );
		else
			handleThread = CMThreadManager::getInstance()->spawn( CMThread::handleRunner, this, &thredID );
	}
	else 
	{
		if(parameter != NULL)
			handleThread = CMThreadManager::getInstance()->spawn( m_StartRoutine, parameter, &thredID );
		else
			handleThread = CMThreadManager::getInstance()->spawn( m_StartRoutine, this, &thredID );
	}

	isStarted = true;
}

DWORD WINAPI CMThread::handleRunner( LPVOID parameter )
{
	CMThread* pThread = ( CMThread* )parameter;

	pThread->run();

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -