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

📄 thread.h

📁 source code for mini mario
💻 H
字号:
#pragma once


#ifndef KBCAFE_THREAD_H
#define KBCAFE_THREAD_H
#ifdef _WIN32
#ifndef _WINDOWS_
#include <windows.h>
#endif
#else
#error _WIN32 must be defined before you include thread.h
#endif
namespace kbcafe
{
class thread
{
#ifdef _WIN32
static DWORD WINAPI ThreadFunc(LPVOID pv)
{
try
{
(reinterpret_cast<thread *>(pv))->run();
}
catch(...)
{
}
return 0;
}
#elif defined(__sun)
#else
#endif
public:
	#ifdef _WIN32
typedef DWORD threadid;
#elif defined(__sun)
#else
#endif
thread()
{
}
virtual ~thread()
{
}
static threadid getthreadid()
{
#ifdef _WIN32
return ::GetCurrentThreadId();
#elif defined(__sun)
#else
#endif
}
static void sleep(long milliseconds=1)
{
#ifdef _WIN32
::Sleep(milliseconds);
#elif defined(__sun)
#else
#endif
}
threadid start()
{
threadid id;
#ifdef _WIN32
::CreateThread(NULL, 0, ThreadFunc, this, 0, &id);
#elif defined(__sun)
#else
#endif
return id;
}
virtual void run()=0;
};
};
#endif

⌨️ 快捷键说明

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