AuroraRuntime/Source/Threading/Primitives/ConditionVariable.Generic.hpp
2021-06-27 22:25:29 +01:00

39 lines
983 B
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ConditionVariable.Generic.hpp
Date: 2021-6-14
Author: Reece
***/
#pragma once
#include "IConditionMutexEx.hpp"
#if defined(AURORA_PLATFORM_WIN32)
#include "ConditionVariable.Win32.hpp"
#elif defined(_AU_HASPTHREAD)
#include "ConditionVariable.Unix.hpp"
#else
#define _AURUNTIME_GENERICCV
#include "ConditionMutex.Generic.hpp"
namespace Aurora::Threading::Primitives
{
class ConditionVariableImpl : public IConditionVariable
{
public:
ConditionVariableImpl(IConditionMutex *mutex);
IConditionMutex *GetMutex() override;
bool WaitForSignal(AuUInt32 timeout) override;
void Signal() override;
void Broadcast() override;
private:
std::atomic_int signals_, waiting_;
ConditionMutexImpl mutex_;
};
}
#endif