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

42 lines
1.1 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuConditionVariable.Unix.hpp
Date: 2021-6-12
Author: Reece
***/
#pragma once
#if !defined(_AURUNTIME_GENERICCV)
#include "AuConditionMutex.Unix.hpp"
namespace Aurora::Threading::Primitives
{
struct ConditionVariableImpl final : IConditionVariable
{
ConditionVariableImpl(const AuSPtr<IConditionMutex> &mutex);
~ConditionVariableImpl();
AuSPtr<IConditionMutex> GetMutex() override;
bool WaitForSignal(AuUInt32 timeout) override;
bool WaitForSignalNsEx(const std::shared_ptr<UnixConditionMutex> &pMutex, AuUInt64 timeout);
bool WaitForSignalNS(AuUInt64 qwTimeout) override;
void Signal() override;
void Broadcast() override;
pthread_cond_t pthreadCv_;
private:
AuSPtr<UnixConditionMutex> mutex_;
};
struct CondVarDummy : IConditionVariable
{
pthread_cond_t pthreadCv_;
};
using ConditionVariableInternal = ConditionVariableImpl;
static const auto kSizeOfDummyCondVar = sizeof(CondVarDummy);
}
#endif