38 lines
1007 B
C++
38 lines
1007 B
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: AuConditionVariable.Generic.hpp
|
|
Date: 2021-6-14
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
#include "AuIConditionMutexEx.hpp"
|
|
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
#include "AuConditionVariable.NT.hpp"
|
|
#elif defined(AURORA_HAS_PTHREADS)
|
|
#include "AuConditionVariable.Unix.hpp"
|
|
#else
|
|
#define _AURUNTIME_GENERICCV
|
|
#include "AuConditionMutex.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
|