2022-04-05 05:59:23 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: LSSemaphore.Linux.hpp
|
|
|
|
Date: 2022-4-5
|
|
|
|
Author: Reece
|
|
|
|
***/
|
2021-10-02 10:28:49 +00:00
|
|
|
#pragma once
|
2022-04-05 10:11:19 +00:00
|
|
|
#include "LSHandle.hpp"
|
2021-10-02 10:28:49 +00:00
|
|
|
|
2022-06-11 23:52:46 +00:00
|
|
|
namespace Aurora::IO::Loop
|
2021-10-02 10:28:49 +00:00
|
|
|
{
|
2022-05-04 15:34:02 +00:00
|
|
|
struct LSSemaphore : ILSSemaphore, virtual LSHandle
|
2022-04-05 05:59:23 +00:00
|
|
|
{
|
2023-10-21 03:31:00 +00:00
|
|
|
LSSemaphore();
|
2022-04-05 05:59:23 +00:00
|
|
|
LSSemaphore(AuUInt32 initialCount);
|
2022-04-14 19:40:35 +00:00
|
|
|
LSSemaphore(int handle, int tag);
|
2022-04-07 01:20:46 +00:00
|
|
|
~LSSemaphore();
|
2022-04-05 05:59:23 +00:00
|
|
|
|
2023-10-21 03:31:00 +00:00
|
|
|
bool TryInit(AuUInt32 initialCount = 0);
|
|
|
|
|
2022-04-05 05:59:23 +00:00
|
|
|
bool AddOne() override;
|
2023-10-22 05:11:39 +00:00
|
|
|
bool AddMany(AuUInt32 uCount) override;
|
|
|
|
|
2022-04-05 05:59:23 +00:00
|
|
|
|
|
|
|
virtual bool OnTrigger(AuUInt handle) override;
|
|
|
|
|
|
|
|
bool IsSignaled() override;
|
2022-04-12 21:26:15 +00:00
|
|
|
bool WaitOn(AuUInt32 timeout) override;
|
2022-04-05 05:59:23 +00:00
|
|
|
virtual ELoopSource GetType() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void Init(AuUInt32 initialCount);
|
|
|
|
bool IsSignaledNonblocking();
|
|
|
|
};
|
2021-10-02 10:28:49 +00:00
|
|
|
}
|