0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-29 16:55:47 +00:00
Ryujinx/Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncContext.cs

79 lines
2.1 KiB
C#
Raw Normal View History

using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Services.Account.Acc.AsyncContext;
using Ryujinx.Horizon.Common;
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)
{
if (context.Process.HandleTable.GenerateHandle(AsyncExecution.SystemEvent.ReadableEvent, out int _systemEventHandle) != Result.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;
}
}
}