AuroraRuntime/Include/Aurora/Threading/Primitives/SpinLock.hpp

33 lines
746 B
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: SpinLock.hpp
Date: 2021-6-9
Author: Reece
***/
#pragma once
namespace Aurora::Threading::Primitives
{
// NOTE: A SPINLOCK CAN NOT BE AN IWAITABLE BY DEFINITION
// Partial interface support exists for completeness alone!
class AUKN_SYM SpinLock : public IWaitable
{
public:
SpinLock();
bool HasOSHandle(AuMach &mach) override;
bool HasLockImplementation() override;
bool Lock(AuUInt64 timeout) override;
bool TryLock() override;
void Lock() override;
void Unlock() override;
private:
AuAtomicInt value_;
2021-06-27 21:25:29 +00:00
};
AUKN_SHARED_API(SpinLock, SpinLock);
}