53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
|
/***
|
||
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||
|
|
||
|
File: BooleanWaitable.hpp
|
||
|
Date: 2021-6-10
|
||
|
Author: Reece
|
||
|
***/
|
||
|
#pragma once
|
||
|
|
||
|
namespace Aurora::Threading::Waitables
|
||
|
{
|
||
|
class BooleanWaitable : public IWaitable
|
||
|
{
|
||
|
public:
|
||
|
BooleanWaitable(std::atomic<bool> &value) : value_(value)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
bool TryLock() override
|
||
|
{
|
||
|
return value_;
|
||
|
}
|
||
|
|
||
|
bool HasOSHandle(AuMach &mach) override
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
bool HasLockImplementation() override
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
void Unlock() override
|
||
|
{
|
||
|
SysPanic("BooleanWaitable is incompatible with WaitFor given an array of IWaitables");
|
||
|
}
|
||
|
|
||
|
void Lock() override
|
||
|
{
|
||
|
SysPanic("BooleanWaitable is not lockable");
|
||
|
}
|
||
|
|
||
|
bool Lock(AuUInt64 timeout) override
|
||
|
{
|
||
|
SysPanic("BooleanWaitable is not lockable");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
std::atomic<bool> &value_;
|
||
|
};
|
||
|
}
|