Fix thread safe
This commit is contained in:
parent
36c73530e4
commit
f5cff1c717
1 changed files with 18 additions and 9 deletions
|
@ -14,7 +14,8 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
||||||
private KEvent _accumulatedSuspendedTickChangedEvent;
|
private KEvent _accumulatedSuspendedTickChangedEvent;
|
||||||
private int _accumulatedSuspendedTickChangedEventHandle = 0;
|
private int _accumulatedSuspendedTickChangedEventHandle = 0;
|
||||||
|
|
||||||
private int _fatalSectionCount;
|
private object _fatalSectionLock = new object();
|
||||||
|
private int _fatalSectionCount;
|
||||||
|
|
||||||
// TODO: Set this when the game goes in suspension (go back to home menu ect), we currently don't support that so we can keep it set to 0.
|
// TODO: Set this when the game goes in suspension (go back to home menu ect), we currently don't support that so we can keep it set to 0.
|
||||||
private ulong _accumulatedSuspendedTickValue = 0;
|
private ulong _accumulatedSuspendedTickValue = 0;
|
||||||
|
@ -57,7 +58,10 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
||||||
// EnterFatalSection()
|
// EnterFatalSection()
|
||||||
public ResultCode EnterFatalSection(ServiceCtx context)
|
public ResultCode EnterFatalSection(ServiceCtx context)
|
||||||
{
|
{
|
||||||
Interlocked.Increment(ref _fatalSectionCount);
|
lock (_fatalSectionLock)
|
||||||
|
{
|
||||||
|
_fatalSectionCount++;
|
||||||
|
}
|
||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
@ -66,16 +70,21 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
||||||
// LeaveFatalSection()
|
// LeaveFatalSection()
|
||||||
public ResultCode LeaveFatalSection(ServiceCtx context)
|
public ResultCode LeaveFatalSection(ServiceCtx context)
|
||||||
{
|
{
|
||||||
if (_fatalSectionCount < 0)
|
ResultCode result = ResultCode.Success;
|
||||||
|
|
||||||
|
lock (_fatalSectionLock)
|
||||||
{
|
{
|
||||||
return ResultCode.UnbalancedFatalSection;
|
if (_fatalSectionCount != 0)
|
||||||
}
|
{
|
||||||
else
|
_fatalSectionCount--;
|
||||||
{
|
}
|
||||||
Interlocked.Decrement(ref _fatalSectionCount);
|
else
|
||||||
|
{
|
||||||
|
result = ResultCode.UnbalancedFatalSection;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResultCode.Success;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command(9)]
|
[Command(9)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue