2021-06-27 21:25:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: CBWaitable.hpp
|
|
|
|
Date: 2021-6-10
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Aurora::Threading::Waitables
|
|
|
|
{
|
|
|
|
class CBWaitable : public IWaitable
|
|
|
|
{
|
|
|
|
public:
|
2022-02-19 11:43:57 +00:00
|
|
|
CBWaitable(const AuFunction<bool()> &value) : callback_(value)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TryLock() override
|
|
|
|
{
|
|
|
|
return callback_();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HasOSHandle(AuMach &mach) override
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HasLockImplementation() override
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Unlock() override
|
|
|
|
{
|
|
|
|
SysPanic("CBWaitable is incompatible with WaitFor given an array of IWaitables");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Lock() override
|
|
|
|
{
|
|
|
|
SysPanic("CBWaitable is not lockable");
|
|
|
|
}
|
|
|
|
|
2023-04-03 07:21:44 +00:00
|
|
|
bool LockMS(AuUInt64 timeout) override
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
|
|
|
SysPanic("CBWaitable is not lockable");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2022-02-19 11:43:57 +00:00
|
|
|
AuFunction<bool()> callback_;
|
2021-06-27 21:25:29 +00:00
|
|
|
};
|
|
|
|
}
|