mirror of
https://github.com/celisej567/mcpe.git
synced 2025-12-31 17:49:17 +03:00
75 lines
1.3 KiB
C++
75 lines
1.3 KiB
C++
/********************************************************************
|
|
Minecraft: Pocket Edition - Decompilation Project
|
|
Copyright (C) 2023 iProgramInCpp
|
|
|
|
The following code is licensed under the BSD 1 clause license.
|
|
SPDX-License-Identifier: BSD-1-Clause
|
|
********************************************************************/
|
|
|
|
#pragma once
|
|
|
|
// CThread - Object oriented pthread wrapper
|
|
|
|
#if defined(_WIN32)
|
|
|
|
#if defined(_XBOX) || defined(USE_OLD_CPP)
|
|
// USE_WIN32_THREADS - Use a Win32 implementation of threads instead of using pthread
|
|
#define USE_WIN32_THREADS
|
|
#else
|
|
// USE_CPP11_THREADS - Use a C++11 implementation of threads instead of using pthread
|
|
#define USE_CPP11_THREADS
|
|
#endif
|
|
|
|
#else
|
|
|
|
#define USE_PTHREADS
|
|
|
|
#endif
|
|
|
|
#ifdef USE_CPP11_THREADS
|
|
// C++11
|
|
#include <thread>
|
|
|
|
#elif defined(USE_WIN32_THREADS)
|
|
|
|
// win32
|
|
#include <stdint.h>
|
|
|
|
#ifdef _XBOX
|
|
#include <xtl.h>
|
|
#else
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#include <Windows.h>
|
|
#endif
|
|
|
|
#else
|
|
|
|
// pthreads
|
|
#include <pthread.h>
|
|
|
|
#endif
|
|
|
|
typedef void* (*CThreadFunction)(void*);
|
|
|
|
class CThread
|
|
{
|
|
public:
|
|
CThread(CThreadFunction, void* param);
|
|
~CThread();
|
|
|
|
static void sleep(uint32_t ms);
|
|
|
|
private:
|
|
CThreadFunction m_func;
|
|
|
|
#ifdef USE_CPP11_THREADS
|
|
std::thread m_thrd;
|
|
#elif defined (USE_WIN32_THREADS)
|
|
HANDLE m_thrd;
|
|
#else
|
|
pthread_t m_thrd;
|
|
pthread_attr_t m_thrd_attr;
|
|
#endif
|
|
};
|
|
|