mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-09-11 18:28:50 +02:00
* IPC refactor part 3 + 4: New server HIPC message processor with source generator based serialization * Make types match on calls to AlignUp/AlignDown * Formatting * Address some PR feedback * Move BitfieldExtensions to Ryujinx.Common.Utilities and consolidate implementations * Rename Reader/Writer to SpanReader/SpanWriter and move to Ryujinx.Common.Memory * Implement EventType * Address more PR feedback * Log request processing errors since they are not normal * Rename waitable to multiwait and add missing lock * PR feedback * Ac_K PR feedback
89 lines
2.6 KiB
C#
89 lines
2.6 KiB
C#
using Ryujinx.Horizon.Common;
|
|
|
|
namespace Ryujinx.Horizon.Sdk.OsTypes.Impl
|
|
{
|
|
static class InterProcessEvent
|
|
{
|
|
public static Result Create(ref InterProcessEventType ipEvent, EventClearMode clearMode)
|
|
{
|
|
Result result = InterProcessEventImpl.Create(out int writableHandle, out int readableHandle);
|
|
|
|
if (result != Result.Success)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
ipEvent = new InterProcessEventType(
|
|
clearMode == EventClearMode.AutoClear,
|
|
true,
|
|
true,
|
|
readableHandle,
|
|
writableHandle);
|
|
|
|
return Result.Success;
|
|
}
|
|
|
|
public static void Destroy(ref InterProcessEventType ipEvent)
|
|
{
|
|
ipEvent.State = InitializationState.NotInitialized;
|
|
|
|
if (ipEvent.ReadableHandleManaged)
|
|
{
|
|
if (ipEvent.ReadableHandle != 0)
|
|
{
|
|
InterProcessEventImpl.Close(ipEvent.ReadableHandle);
|
|
}
|
|
ipEvent.ReadableHandleManaged = false;
|
|
}
|
|
|
|
if (ipEvent.WritableHandleManaged)
|
|
{
|
|
if (ipEvent.WritableHandle != 0)
|
|
{
|
|
InterProcessEventImpl.Close(ipEvent.WritableHandle);
|
|
}
|
|
ipEvent.WritableHandleManaged = false;
|
|
}
|
|
}
|
|
|
|
public static int DetachReadableHandle(ref InterProcessEventType ipEvent)
|
|
{
|
|
int handle = ipEvent.ReadableHandle;
|
|
|
|
ipEvent.ReadableHandle = 0;
|
|
ipEvent.ReadableHandleManaged = false;
|
|
|
|
return handle;
|
|
}
|
|
|
|
public static int DetachWritableHandle(ref InterProcessEventType ipEvent)
|
|
{
|
|
int handle = ipEvent.WritableHandle;
|
|
|
|
ipEvent.WritableHandle = 0;
|
|
ipEvent.WritableHandleManaged = false;
|
|
|
|
return handle;
|
|
}
|
|
|
|
public static int GetReadableHandle(ref InterProcessEventType ipEvent)
|
|
{
|
|
return ipEvent.ReadableHandle;
|
|
}
|
|
|
|
public static int GetWritableHandle(ref InterProcessEventType ipEvent)
|
|
{
|
|
return ipEvent.WritableHandle;
|
|
}
|
|
|
|
public static void Signal(ref InterProcessEventType ipEvent)
|
|
{
|
|
InterProcessEventImpl.Signal(ipEvent.WritableHandle);
|
|
}
|
|
|
|
public static void Clear(ref InterProcessEventType ipEvent)
|
|
{
|
|
InterProcessEventImpl.Clear(ipEvent.ReadableHandle == 0 ? ipEvent.WritableHandle : ipEvent.ReadableHandle);
|
|
}
|
|
}
|
|
}
|