2023-12-07 09:20:23 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021-2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: AuAsyncTimer.hpp
|
|
|
|
Date: 2023-12-06
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "WorkItem.hpp"
|
|
|
|
|
|
|
|
namespace Aurora::Async
|
|
|
|
{
|
|
|
|
struct AsyncFuncTimer :
|
|
|
|
WorkItem,
|
|
|
|
IAsyncTimer
|
|
|
|
{
|
|
|
|
AsyncFuncTimer(IThreadPoolInternal *owner,
|
|
|
|
const AuSPtr<IAsyncTimerCallback> &pCallback,
|
|
|
|
const WorkerPId_t &worker,
|
|
|
|
AuUInt64 uNextTickTime,
|
|
|
|
AuUInt64 uInterval);
|
|
|
|
|
|
|
|
void CancelTimer() override;
|
|
|
|
AuUInt64 GetLastTime() override;
|
|
|
|
AuUInt64 GetTicks() override;
|
2024-05-19 16:01:51 +00:00
|
|
|
bool IsCatchUp() override;
|
|
|
|
void SetCatchUp(bool bCatchUp) override;
|
2023-12-07 09:20:23 +00:00
|
|
|
|
|
|
|
void DispatchTask(IWorkItemHandler::ProcessInfo &info) override;
|
|
|
|
void Cleanup() override;
|
|
|
|
private:
|
|
|
|
AuSPtr<IAsyncTimerCallback> pCallback;
|
|
|
|
WorkerPId_t worker;
|
|
|
|
AuUInt64 uNextTickTime {};
|
|
|
|
AuUInt64 uLastTickTime {};
|
|
|
|
AuUInt64 uInterval {};
|
|
|
|
AuUInt64 uTickCount {};
|
2024-05-19 16:01:51 +00:00
|
|
|
bool bCatchUp { false };
|
2024-05-28 16:28:14 +00:00
|
|
|
AuCriticalSection mutex;
|
2023-12-07 09:20:23 +00:00
|
|
|
};
|
|
|
|
}
|