Files
CPP_Core/psc_global_include/Spin_Lock.h
T
2026-06-16 10:56:40 +08:00

21 lines
465 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;
};
}
#endif