Esempio n. 1
0
        // SetCurrentTime(nn::time::PosixTime)
        public ResultCode SetCurrentTime(ServiceCtx context)
        {
            if (!_writePermission)
            {
                return(ResultCode.PermissionDenied);
            }

            long                 posixTime        = context.RequestData.ReadInt64();
            SteadyClockCore      steadyClockCore  = _clockCore.GetSteadyClockCore();
            SteadyClockTimePoint currentTimePoint = steadyClockCore.GetCurrentTimePoint(context.Thread);

            SystemClockContext clockContext = new SystemClockContext()
            {
                Offset          = posixTime - currentTimePoint.TimePoint,
                SteadyTimePoint = currentTimePoint
            };

            ResultCode result = _clockCore.SetSystemClockContext(clockContext);

            if (result == ResultCode.Success)
            {
                result = _clockCore.Flush(clockContext);
            }

            return(result);
        }
Esempio n. 2
0
        // SetClockContext(nn::time::SystemClockContext)
        public ResultCode SetSystemClockContext(ServiceCtx context)
        {
            if (!_writePermission)
            {
                return(ResultCode.PermissionDenied);
            }

            if (!_bypassUninitializedClock && !_clockCore.IsInitialized())
            {
                return(ResultCode.UninitializedClock);
            }

            SystemClockContext clockContext = context.RequestData.ReadStruct <SystemClockContext>();

            ResultCode result = _clockCore.SetSystemClockContext(clockContext);

            return(result);
        }