1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-21 10:32:01 +00:00
Ryujinx/Ryujinx.HLE/HOS/Kernel/Threading/KReadableEvent.cs
gdkchan 15d1cc806b
Move kernel state out of the Horizon class (#1107)
* Move kernel state from Horizon to KernelContext

* Merge syscalls partial classes, split 32 and 64-bit variants

* Sort usings
2020-05-04 13:41:29 +10:00

64 lines
No EOL
1.3 KiB
C#

using Ryujinx.HLE.HOS.Kernel.Common;
namespace Ryujinx.HLE.HOS.Kernel.Threading
{
class KReadableEvent : KSynchronizationObject
{
private readonly KEvent _parent;
private bool _signaled;
public KReadableEvent(KernelContext context, KEvent parent) : base(context)
{
_parent = parent;
}
public override void Signal()
{
KernelContext.CriticalSection.Enter();
if (!_signaled)
{
_signaled = true;
base.Signal();
}
KernelContext.CriticalSection.Leave();
}
public KernelResult Clear()
{
_signaled = false;
return KernelResult.Success;
}
public KernelResult ClearIfSignaled()
{
KernelResult result;
KernelContext.CriticalSection.Enter();
if (_signaled)
{
_signaled = false;
result = KernelResult.Success;
}
else
{
result = KernelResult.InvalidState;
}
KernelContext.CriticalSection.Leave();
return result;
}
public override bool IsSignaled()
{
return _signaled;
}
}
}