2022-04-19 21:50:34 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: LSTimer.NT.hpp
|
|
|
|
Date: 2022-4-19
|
|
|
|
Author: Reece
|
|
|
|
***/
|
2021-10-02 10:28:49 +00:00
|
|
|
#pragma once
|
2022-04-19 21:50:34 +00:00
|
|
|
#include "LSHandle.hpp"
|
|
|
|
|
2022-06-11 23:52:46 +00:00
|
|
|
namespace Aurora::IO::Loop
|
2021-10-02 10:28:49 +00:00
|
|
|
{
|
2022-06-11 23:52:46 +00:00
|
|
|
struct LSTimer : ITimer, virtual LSHandle
|
2022-05-04 15:34:02 +00:00
|
|
|
{
|
|
|
|
LSTimer(AuUInt32 reschedStepMsOrZero, AuUInt32 maxIterationsOrZero, bool bSingleshot, int handle);
|
|
|
|
~LSTimer();
|
|
|
|
|
|
|
|
virtual void UpdateTime(AuUInt64 absTimeMs) override;
|
|
|
|
virtual void UpdateTimeNs(AuUInt64 absTimeNs) override;
|
|
|
|
virtual void UpdateTickRateIfAny(AuUInt32 reschedStepMsOrZero, AuUInt32 maxIterationsOrZero) override;
|
|
|
|
virtual void UpdateTickRateIfAnyNs(AuUInt64 reschedStepNsOrZero, AuUInt32 maxIterationsOrZero) override;
|
|
|
|
virtual void Stop() override;
|
|
|
|
|
|
|
|
virtual bool OnTrigger(AuUInt handle) override;
|
|
|
|
|
|
|
|
virtual bool IsSignaled() override;
|
|
|
|
virtual bool WaitOn(AuUInt32 timeout) override;
|
|
|
|
virtual ELoopSource GetType() override;
|
|
|
|
|
|
|
|
void UpdateTimeInternal(AuUInt64 absTimeMs);
|
|
|
|
|
|
|
|
private:
|
|
|
|
AuUInt32 maxIterationsOrZero_ {};
|
2022-08-02 04:52:17 +00:00
|
|
|
AuUInt64 reschedStepNsOrZero_ {}, targetTime_ {};
|
2022-05-04 15:34:02 +00:00
|
|
|
AuUInt32 count_ {};
|
|
|
|
bool bSingleshot {};
|
|
|
|
|
|
|
|
bool IsSignaledNonblocking();
|
|
|
|
};
|
2021-10-02 10:28:49 +00:00
|
|
|
}
|