Files
MapLibreParticleLab/platform/windows/include/thread.h
Bart Louwers 550f64be22 core: rename mbgl namespace to mln (#4487)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-08-14 23:25:20 +02:00

68 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 mln {
namespace platform {
std::string getCurrentThreadName();
void setCurrentThreadName(const std::string& name);
void makeThreadLowPriority();
void setCurrentThreadPriority(double priority);
} // namespace platform
} // namespace mln
#endif