38 lines
997 B
C++
38 lines
997 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_IS_MODERNNT_DERIVED)
|
|
#include "ConditionVariable.NT.hpp"
|
|
#elif defined(AURORA_HAS_PTHREADS)
|
|
#include "ConditionVariable.Unix.hpp"
|
|
#else
|
|
#define _AURUNTIME_GENERICCV
|
|
#include "ConditionMutex.Generic.hpp"
|
|
|
|
namespace Aurora::Threading::Primitives
|
|
{
|
|
struct ConditionVariableImpl : IConditionVariable
|
|
{
|
|
ConditionVariableImpl(const AuSPtr<IConditionMutex> &mutex);
|
|
|
|
AuSPtr<IConditionMutex> GetMutex() override;
|
|
bool WaitForSignal(AuUInt32 timeout) override;
|
|
void Signal() override;
|
|
void Broadcast() override;
|
|
|
|
private:
|
|
std::atomic_int signals_, waiting_;
|
|
AuSPtr<ConditionMutexImpl> mutex_;
|
|
|
|
};
|
|
}
|
|
#endif
|