AuroraRuntime/Source/Threading/Primitives/AuCriticalSection.hpp
Reece 046b70d7bc [*] [Pre-Win8.1] Optimize for modern nt instead of windows vista synch in legacy path; yes, this is how windows 7 and vista synch is somewhat implemented.
...on apis that predate those kernel revisions. so, technically this might be able to run on xp.
[*] GetThreadCookie optimization for all platforms
2023-03-15 00:35:29 +00:00

33 lines
767 B
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuCriticalSection.hpp
Date: 2021-6-12
Author: Reece
***/
#pragma once
#include "AuMutex.Generic.hpp"
#include "ThreadCookie.hpp"
namespace Aurora::Threading::Primitives
{
struct CriticalSection : IWaitable
{
CriticalSection();
~CriticalSection();
bool HasOSHandle(AuMach &mach) override;
bool HasLockImplementation() override;
bool TryLock() override;
void Lock() override;
bool Lock(AuUInt64 timeout) override;
bool LockNS(AuUInt64 timeout) override;
void Unlock() override;
private:
Mutex mutex_;
ThreadCookie_t owner_;
std::atomic<int> count_;
};
}