2018-09-23 14:11:46 -04:00
|
|
|
namespace Ryujinx.HLE.HOS.Kernel
|
|
|
|
{
|
|
|
|
class KReadableEvent : KSynchronizationObject
|
|
|
|
{
|
2018-12-04 19:52:39 -05:00
|
|
|
private KEvent Parent;
|
2018-09-23 14:11:46 -04:00
|
|
|
|
2018-12-04 19:52:39 -05:00
|
|
|
private bool Signaled;
|
2018-09-23 14:11:46 -04:00
|
|
|
|
2018-12-04 19:52:39 -05:00
|
|
|
public KReadableEvent(Horizon System, KEvent Parent) : base(System)
|
2018-09-23 14:11:46 -04:00
|
|
|
{
|
2018-12-04 19:52:39 -05:00
|
|
|
this.Parent = Parent;
|
2018-09-23 14:11:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void Signal()
|
|
|
|
{
|
2018-11-28 17:18:09 -05:00
|
|
|
System.CriticalSection.Enter();
|
2018-09-23 14:11:46 -04:00
|
|
|
|
2018-12-04 19:52:39 -05:00
|
|
|
if (!Signaled)
|
2018-09-23 14:11:46 -04:00
|
|
|
{
|
2018-12-04 19:52:39 -05:00
|
|
|
Signaled = true;
|
2018-09-23 14:11:46 -04:00
|
|
|
|
|
|
|
base.Signal();
|
|
|
|
}
|
|
|
|
|
2018-11-28 17:18:09 -05:00
|
|
|
System.CriticalSection.Leave();
|
2018-09-23 14:11:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public KernelResult Clear()
|
|
|
|
{
|
2018-12-04 19:52:39 -05:00
|
|
|
Signaled = false;
|
2018-09-23 14:11:46 -04:00
|
|
|
|
|
|
|
return KernelResult.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
public KernelResult ClearIfSignaled()
|
|
|
|
{
|
2018-12-04 19:52:39 -05:00
|
|
|
KernelResult Result;
|
2018-09-23 14:11:46 -04:00
|
|
|
|
2018-11-28 17:18:09 -05:00
|
|
|
System.CriticalSection.Enter();
|
2018-09-23 14:11:46 -04:00
|
|
|
|
2018-12-04 19:52:39 -05:00
|
|
|
if (Signaled)
|
2018-09-23 14:11:46 -04:00
|
|
|
{
|
2018-12-04 19:52:39 -05:00
|
|
|
Signaled = false;
|
2018-09-23 14:11:46 -04:00
|
|
|
|
2018-12-04 19:52:39 -05:00
|
|
|
Result = KernelResult.Success;
|
2018-09-23 14:11:46 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-04 19:52:39 -05:00
|
|
|
Result = KernelResult.InvalidState;
|
2018-09-23 14:11:46 -04:00
|
|
|
}
|
|
|
|
|
2018-11-28 17:18:09 -05:00
|
|
|
System.CriticalSection.Leave();
|
2018-09-23 14:11:46 -04:00
|
|
|
|
2018-12-04 19:52:39 -05:00
|
|
|
return Result;
|
2018-09-23 14:11:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public override bool IsSignaled()
|
|
|
|
{
|
2018-12-04 19:52:39 -05:00
|
|
|
return Signaled;
|
2018-09-23 14:11:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|