mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-24 13:30:18 +00:00
21 lines
334 B
C++
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
|