AuroraRuntime/Source/IO/IPC/AuIPCMutexFutex.Linux.hpp
2022-12-14 05:03:37 +00:00

48 lines
1.1 KiB
C++

#pragma once
#include "AuIPCHandle.hpp"
#include "AuIPCPrimitives.Linux.hpp"
namespace Aurora::IO::IPC
{
struct IMutexClosedHook
{
virtual bool OnClosed() = 0;
};
struct IPCPipeImpl;
struct IPCMutexProxy : IPCMutex, Loop::ILoopSourceEx, AuEnableSharedFromThis<IPCMutexProxy>, IMutexClosedHook
{
IPCMutexProxy(AuUInt32 index);
IPCMutexProxy(int handle, AuSPtr<IPCSharedMemory> mem, AuUInt32 index);
~IPCMutexProxy();
PROXY_INTERNAL_INTERFACE(mutex_)
bool OnClosed() override;
bool Unlock() override;
bool IsSignaled() override;
bool WaitOn(AuUInt32 timeout) override;
Loop::ELoopSource GetType() override;
AuString ExportToString() override;
AuUInt32 *GetFutex();
IMutexClosedHook *pMutexClosedHook {};
private:
bool bOwned {};
IPCToken token_;
AuSPtr<IPCSharedMemory> mem_;
AuUInt32 index_;
Loop::LSMutex mutex_;
AuSPtr<void> leakSelf_;
friend IPCPipeImpl;
};
AuSPtr<IPCMutexProxy> ImportMutexEx(const IPCToken &handle, const IPCToken &mem, AuUInt32 index);
}