AuroraRuntime/Source/Threading/Primitives/AuConditionVariable.Generic.hpp

38 lines
1007 B
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
2022-11-17 07:46:07 +00:00
File: AuConditionVariable.Generic.hpp
2021-06-27 21:25:29 +00:00
Date: 2021-6-14
Author: Reece
***/
#pragma once
2022-11-17 07:46:07 +00:00
#include "AuIConditionMutexEx.hpp"
2021-06-27 21:25:29 +00:00
2021-09-06 10:58:08 +00:00
#if defined(AURORA_IS_MODERNNT_DERIVED)
2022-11-17 07:46:07 +00:00
#include "AuConditionVariable.NT.hpp"
2021-09-06 10:58:08 +00:00
#elif defined(AURORA_HAS_PTHREADS)
2022-11-17 07:46:07 +00:00
#include "AuConditionVariable.Unix.hpp"
2021-06-27 21:25:29 +00:00
#else
#define _AURUNTIME_GENERICCV
2022-11-17 07:46:07 +00:00
#include "AuConditionMutex.Generic.hpp"
2021-06-27 21:25:29 +00:00
namespace Aurora::Threading::Primitives
{
2022-06-01 21:49:38 +00:00
struct ConditionVariableImpl : IConditionVariable
2021-06-27 21:25:29 +00:00
{
ConditionVariableImpl(const AuSPtr<IConditionMutex> &mutex);
2021-06-27 21:25:29 +00:00
AuSPtr<IConditionMutex> GetMutex() override;
2021-06-27 21:25:29 +00:00
bool WaitForSignal(AuUInt32 timeout) override;
void Signal() override;
void Broadcast() override;
private:
std::atomic_int signals_, waiting_;
AuSPtr<ConditionMutexImpl> mutex_;
2021-06-27 21:25:29 +00:00
};
}
#endif