2018-09-23 19:11:46 +01:00
|
|
|
namespace Ryujinx.HLE.HOS.Kernel
|
|
|
|
{
|
|
|
|
class KReadableEvent : KSynchronizationObject
|
|
|
|
{
|
2018-12-01 20:01:59 +00:00
|
|
|
private KEvent _parent;
|
2018-09-23 19:11:46 +01:00
|
|
|
|
2018-12-01 20:01:59 +00:00
|
|
|
private bool _signaled;
|
2018-09-23 19:11:46 +01:00
|
|
|
|
2018-12-01 20:01:59 +00:00
|
|
|
public KReadableEvent(Horizon system, KEvent parent) : base(system)
|
2018-09-23 19:11:46 +01:00
|
|
|
{
|
2018-12-01 20:24:37 +00:00
|
|
|
_parent = parent;
|
2018-09-23 19:11:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void Signal()
|
|
|
|
{
|
2018-11-28 22:18:09 +00:00
|
|
|
System.CriticalSection.Enter();
|
2018-09-23 19:11:46 +01:00
|
|
|
|
2018-12-01 20:01:59 +00:00
|
|
|
if (!_signaled)
|
2018-09-23 19:11:46 +01:00
|
|
|
{
|
2018-12-01 20:01:59 +00:00
|
|
|
_signaled = true;
|
2018-09-23 19:11:46 +01:00
|
|
|
|
|
|
|
base.Signal();
|
|
|
|
}
|
|
|
|
|
2018-11-28 22:18:09 +00:00
|
|
|
System.CriticalSection.Leave();
|
2018-09-23 19:11:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public KernelResult Clear()
|
|
|
|
{
|
2018-12-01 20:01:59 +00:00
|
|
|
_signaled = false;
|
2018-09-23 19:11:46 +01:00
|
|
|
|
|
|
|
return KernelResult.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
public KernelResult ClearIfSignaled()
|
|
|
|
{
|
2018-12-01 20:01:59 +00:00
|
|
|
KernelResult result;
|
2018-09-23 19:11:46 +01:00
|
|
|
|
2018-11-28 22:18:09 +00:00
|
|
|
System.CriticalSection.Enter();
|
2018-09-23 19:11:46 +01:00
|
|
|
|
2018-12-01 20:01:59 +00:00
|
|
|
if (_signaled)
|
2018-09-23 19:11:46 +01:00
|
|
|
{
|
2018-12-01 20:01:59 +00:00
|
|
|
_signaled = false;
|
2018-09-23 19:11:46 +01:00
|
|
|
|
2018-12-01 20:01:59 +00:00
|
|
|
result = KernelResult.Success;
|
2018-09-23 19:11:46 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-01 20:01:59 +00:00
|
|
|
result = KernelResult.InvalidState;
|
2018-09-23 19:11:46 +01:00
|
|
|
}
|
|
|
|
|
2018-11-28 22:18:09 +00:00
|
|
|
System.CriticalSection.Leave();
|
2018-09-23 19:11:46 +01:00
|
|
|
|
2018-12-01 20:01:59 +00:00
|
|
|
return result;
|
2018-09-23 19:11:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override bool IsSignaled()
|
|
|
|
{
|
2018-12-01 20:01:59 +00:00
|
|
|
return _signaled;
|
2018-09-23 19:11:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|