0
0
Fork 0
This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
ryujinx-final/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs
Ac_K a0720b5681 Refactoring HOS folder structure (#771)
* Refactoring HOS folder structure

Refactoring HOS folder structure:

- Added some subfolders when needed (Following structure decided in private).
- Added some `Types` folders when needed.
- Little cleanup here and there.
- Add services placeholders for every HOS services (close #766 and #753).

* Remove Types namespaces
2019-09-19 10:45:11 +10:00

58 lines
2 KiB
C#

using Ryujinx.HLE.HOS.Kernel.Threading;
namespace Ryujinx.HLE.HOS.Services.Time.Clock
{
class StandardNetworkSystemClockCore : SystemClockCore
{
private TimeSpanType _standardNetworkClockSufficientAccuracy;
private static StandardNetworkSystemClockCore _instance;
public static StandardNetworkSystemClockCore Instance
{
get
{
if (_instance == null)
{
_instance = new StandardNetworkSystemClockCore(StandardSteadyClockCore.Instance);
}
return _instance;
}
}
public StandardNetworkSystemClockCore(StandardSteadyClockCore steadyClockCore) : base(steadyClockCore)
{
_standardNetworkClockSufficientAccuracy = new TimeSpanType(0);
}
public override ResultCode Flush(SystemClockContext context)
{
// TODO: set:sys SetNetworkSystemClockContext
return ResultCode.Success;
}
public bool IsStandardNetworkSystemClockAccuracySufficient(KThread thread)
{
SteadyClockCore steadyClockCore = GetSteadyClockCore();
SteadyClockTimePoint currentTimePoint = steadyClockCore.GetCurrentTimePoint(thread);
bool isStandardNetworkClockSufficientAccuracy = false;
ResultCode result = GetSystemClockContext(thread, out SystemClockContext context);
if (result == ResultCode.Success && context.SteadyTimePoint.GetSpanBetween(currentTimePoint, out long outSpan) == ResultCode.Success)
{
isStandardNetworkClockSufficientAccuracy = outSpan * 1000000000 < _standardNetworkClockSufficientAccuracy.NanoSeconds;
}
return isStandardNetworkClockSufficientAccuracy;
}
public void SetStandardNetworkClockSufficientAccuracy(TimeSpanType standardNetworkClockSufficientAccuracy)
{
_standardNetworkClockSufficientAccuracy = standardNetworkClockSufficientAccuracy;
}
}
}