Files
SourMesen e391fd8f9a Code: Add auto-formatting rules for C++ (clang-format) and enforce in CI via "clang-format" and "dotnet format" (#78)
* Code: Add auto-formatting rules for C++ projects (clang-format) and enforce code style via "clang-format" and "dotnet format"

* fix ui format warnings
2026-04-30 06:03:55 -07:00

44 lines
636 B
C++

#pragma once
#include "pch.h"
#include <thread>
class SimpleLock;
class LockHandler
{
private:
SimpleLock* _lock;
bool _released = false;
public:
LockHandler(SimpleLock* lock);
void Release();
~LockHandler();
};
class SimpleLock
{
private:
thread_local static std::thread::id _threadID;
std::thread::id _holderThreadID;
uint32_t _lockCount;
atomic_flag _lock;
bool WaitForAcquire(uint32_t msTimeout);
public:
SimpleLock();
~SimpleLock();
LockHandler AcquireSafe();
void Acquire();
bool TryAcquire(uint32_t msTimeout);
bool IsFree();
bool IsLockedByCurrentThread();
void WaitForRelease();
void Release();
};