2022-08-02 04:52:17 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-12-14 05:03:37 +00:00
|
|
|
#include "AuIPCHandle.hpp"
|
|
|
|
#include "AuIPCPrimitives.Linux.hpp"
|
2022-08-02 04:52:17 +00:00
|
|
|
|
|
|
|
namespace Aurora::IO::IPC
|
|
|
|
{
|
|
|
|
struct IMutexClosedHook
|
|
|
|
{
|
|
|
|
virtual bool OnClosed() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct IPCPipeImpl;
|
2022-08-07 04:18:34 +00:00
|
|
|
struct IPCMutexProxy : IPCMutex, Loop::ILoopSourceEx, AuEnableSharedFromThis<IPCMutexProxy>, IMutexClosedHook
|
2022-08-02 04:52:17 +00:00
|
|
|
{
|
|
|
|
IPCMutexProxy(AuUInt32 index);
|
|
|
|
IPCMutexProxy(int handle, AuSPtr<IPCSharedMemory> mem, AuUInt32 index);
|
|
|
|
~IPCMutexProxy();
|
|
|
|
|
|
|
|
PROXY_INTERNAL_INTERFACE(mutex_)
|
|
|
|
|
2022-08-07 04:18:34 +00:00
|
|
|
bool OnClosed() override;
|
|
|
|
|
2022-08-02 04:52:17 +00:00
|
|
|
bool Unlock() override;
|
|
|
|
|
2023-12-01 10:33:55 +00:00
|
|
|
bool IsSignaledNoSpinIfUserland() override;
|
2022-08-02 04:52:17 +00:00
|
|
|
bool IsSignaled() override;
|
|
|
|
bool WaitOn(AuUInt32 timeout) override;
|
|
|
|
Loop::ELoopSource GetType() override;
|
|
|
|
|
|
|
|
AuString ExportToString() override;
|
2022-08-07 04:18:34 +00:00
|
|
|
|
|
|
|
AuUInt32 *GetFutex();
|
|
|
|
|
|
|
|
IMutexClosedHook *pMutexClosedHook {};
|
|
|
|
|
2022-08-02 04:52:17 +00:00
|
|
|
private:
|
|
|
|
bool bOwned {};
|
|
|
|
IPCToken token_;
|
|
|
|
AuSPtr<IPCSharedMemory> mem_;
|
|
|
|
AuUInt32 index_;
|
|
|
|
Loop::LSMutex mutex_;
|
2022-08-07 04:18:34 +00:00
|
|
|
AuSPtr<void> leakSelf_;
|
2022-08-02 04:52:17 +00:00
|
|
|
|
|
|
|
friend IPCPipeImpl;
|
|
|
|
};
|
|
|
|
|
2022-08-09 06:48:29 +00:00
|
|
|
AuSPtr<IPCMutexProxy> ImportMutexEx(const IPCToken &handle, const IPCToken &mem, AuUInt32 index);
|
2022-08-02 04:52:17 +00:00
|
|
|
}
|