AuroraRuntime/Source/IO/Loop/LSSemaphore.Linux.hpp

36 lines
839 B
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: LSSemaphore.Linux.hpp
Date: 2022-4-5
Author: Reece
***/
#pragma once
#include "LSHandle.hpp"
namespace Aurora::IO::Loop
{
struct LSSemaphore : ILSSemaphore, virtual LSHandle
{
LSSemaphore();
LSSemaphore(AuUInt32 initialCount);
LSSemaphore(int handle, int tag);
~LSSemaphore();
bool TryInit(AuUInt32 initialCount = 0);
bool AddOne() override;
bool AddMany(AuUInt32 uCount) override;
virtual bool OnTrigger(AuUInt handle) override;
bool IsSignaled() override;
bool WaitOn(AuUInt32 timeout) override;
virtual ELoopSource GetType() override;
private:
void Init(AuUInt32 initialCount);
bool IsSignaledNonblocking();
};
}