2024-06-09 01:39:05 +08:00

21 lines
334 B
C++

#pragma once
#if PK_ENABLE_THREAD
#define PK_THREAD_LOCAL thread_local
#include <mutex>
struct GIL {
inline static std::mutex _mutex;
explicit GIL() { _mutex.lock(); }
~GIL() { _mutex.unlock(); }
};
#define PK_GLOBAL_SCOPE_LOCK() GIL _lock;
#else
#define PK_THREAD_LOCAL static
#define PK_GLOBAL_SCOPE_LOCK()
#endif