0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-12-27 19:45:45 +00:00
ryujinx-fork/Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncContext.cs

79 lines
2.2 KiB
C#
Raw Normal View History

using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Services.Account.Acc.AsyncContext;
using System;
namespace Ryujinx.HLE.HOS.Services.Account.Acc
{
class IAsyncContext : IpcService
{
2022-08-31 17:41:43 +00:00
protected AsyncExecution AsyncExecution;
public IAsyncContext(AsyncExecution asyncExecution)
{
2022-08-31 17:41:43 +00:00
AsyncExecution = asyncExecution;
}
[CommandHipc(0)]
// GetSystemEvent() -> handle<copy>
public ResultCode GetSystemEvent(ServiceCtx context)
{
2022-08-31 17:41:43 +00:00
if (context.Process.HandleTable.GenerateHandle(AsyncExecution.SystemEvent.ReadableEvent, out int _systemEventHandle) != KernelResult.Success)
{
throw new InvalidOperationException("Out of handles!");
}
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_systemEventHandle);
return ResultCode.Success;
}
[CommandHipc(1)]
// Cancel()
public ResultCode Cancel(ServiceCtx context)
{
2022-08-31 17:41:43 +00:00
if (!AsyncExecution.IsInitialized)
{
return ResultCode.AsyncExecutionNotInitialized;
}
2022-08-31 17:41:43 +00:00
if (AsyncExecution.IsRunning)
{
2022-08-31 17:41:43 +00:00
AsyncExecution.Cancel();
}
return ResultCode.Success;
}
[CommandHipc(2)]
// HasDone() -> b8
public ResultCode HasDone(ServiceCtx context)
{
2022-08-31 17:41:43 +00:00
if (!AsyncExecution.IsInitialized)
{
return ResultCode.AsyncExecutionNotInitialized;
}
2022-08-31 17:41:43 +00:00
context.ResponseData.Write(AsyncExecution.SystemEvent.ReadableEvent.IsSignaled());
return ResultCode.Success;
}
[CommandHipc(3)]
// GetResult()
public ResultCode GetResult(ServiceCtx context)
{
2022-08-31 17:41:43 +00:00
if (!AsyncExecution.IsInitialized)
{
return ResultCode.AsyncExecutionNotInitialized;
}
2022-08-31 17:41:43 +00:00
if (!AsyncExecution.SystemEvent.ReadableEvent.IsSignaled())
{
return ResultCode.Unknown41;
}
return ResultCode.Success;
}
}
}