Files
CPP_Core/psc_global_include/Spin_Lock.h
T
2026-07-24 10:54:45 +08:00

22 lines
427 B
C++

#ifndef PSCToolbox_SpinLock_H
#define PSCToolbox_SpinLock_H
#include <atomic>
#include <mutex>
namespace Psc {
struct Empty_Lock {
void lock();
void unlock();
bool tryLock();
bool tryLock(int durationMillis);
};
struct Spin_Lock {
void lock();
bool tryLock();
bool tryLock(int durationMillis);
void unlock();
protected:
std::atomic_flag flag = ATOMIC_FLAG_INIT;
};
} // namespace Psc
#endif