mirror of
https://github.com/libretro/Mesen.git
synced 2024-12-13 03:47:27 +00:00
37 lines
483 B
C++
37 lines
483 B
C++
#pragma once
|
|
#include "stdafx.h"
|
|
#include <thread>
|
|
|
|
class SimpleLock;
|
|
|
|
class LockHandler
|
|
{
|
|
private:
|
|
SimpleLock *_lock;
|
|
public:
|
|
LockHandler(SimpleLock *lock);
|
|
~LockHandler();
|
|
};
|
|
|
|
class SimpleLock
|
|
{
|
|
private:
|
|
thread_local static std::thread::id _threadID;
|
|
|
|
std::thread::id _holderThreadID;
|
|
uint32_t _lockCount;
|
|
atomic_flag _lock;
|
|
|
|
public:
|
|
SimpleLock();
|
|
~SimpleLock();
|
|
|
|
LockHandler AcquireSafe();
|
|
|
|
void Acquire();
|
|
bool IsFree();
|
|
void WaitForRelease();
|
|
void Release();
|
|
};
|
|
|