30 lines
661 B
C++
30 lines
661 B
C++
|
/***
|
||
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||
|
|
||
|
File: Mutex.Win32.hpp
|
||
|
Date: 2021-6-12
|
||
|
Author: Reece
|
||
|
***/
|
||
|
#pragma once
|
||
|
|
||
|
namespace Aurora::Threading::Primitives
|
||
|
{
|
||
|
class Mutex : public IWaitable
|
||
|
{
|
||
|
public:
|
||
|
Mutex();
|
||
|
~Mutex();
|
||
|
|
||
|
bool HasOSHandle(AuMach &mach) override;
|
||
|
bool TryLock() override;
|
||
|
bool HasLockImplementation() override;
|
||
|
void Lock() override;
|
||
|
bool Lock(AuUInt64 timeout) override;
|
||
|
void Unlock() override;
|
||
|
|
||
|
private:
|
||
|
SRWLOCK atomicHolder_;
|
||
|
CONDITION_VARIABLE wakeup_;
|
||
|
volatile AuAtomicInt state_{};
|
||
|
};
|
||
|
}
|