Files
MapLibreParticleLab/platform/windows/include/thread.h
tdcosta100 f06f60803c Add windows support (#707)
Co-authored-by: acalcutt <acalcutt@techidiots.net>
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
Co-authored-by: Ovidiu Voda <ovi.voda@gmail.com>
2023-02-25 16:12:06 -05:00

73 lines
1.4 KiB
C++

#pragma once
#ifndef _thread_h_
#define _thread_h_
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
// https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code?view=vs-2022
//
// Usage: SetThreadName (-1, "MainThread");
//
//
// Usage: SetThreadName ((DWORD)-1, "MainThread");
//
const DWORD MS_VC_EXCEPTION = 0x406D1388;
#pragma pack(push,8)
typedef struct tagTHREADNAME_INFO
{
DWORD dwType; // Must be 0x1000.
LPCSTR szName; // Pointer to name (in user addr space).
DWORD dwThreadID; // Thread ID (-1=caller thread).
DWORD dwFlags; // Reserved for future use, must be zero.
} THREADNAME_INFO;
#pragma pack(pop)
void SetThreadName(DWORD dwThreadID, const char* threadName);
typedef struct structTHREAD_INFO {
DWORD id;
DWORD key;
char* name;
} THREAD_INFO;
#ifdef __cplusplus
}
#endif
extern DWORD selfThreadKey;
class DummyClassThread {
public:
DummyClassThread() {
selfThreadKey = TlsAlloc();
}
~DummyClassThread() {
TlsFree(selfThreadKey);
}
};
extern DummyClassThread dummyClassThread;
THREAD_INFO* GetCurrentThreadInfo();
namespace mbgl {
namespace platform {
std::string getCurrentThreadName();
void setCurrentThreadName(const std::string& name);
void makeThreadLowPriority();
void setCurrentThreadPriority(double priority);
}
}
#endif