29#ifndef Pt_System_Timer_h
30#define Pt_System_Timer_h
32#include <Pt/System/Api.h>
34#include <Pt/Timespan.h>
37#if __cplusplus >= 202002L
38#include <Pt/Coroutine.h>
161 {
return _finished; }
163#if __cplusplus >= 202002L
180#if __cplusplus >= 202002L
181 friend class AsyncWait;
183 void attachAwaiter(AsyncWait& awaiter);
185 void detachAwaiter(AsyncWait& awaiter);
190 std::size_t _interval;
195 #if __cplusplus >= 202002L
196 AsyncWait* _awaiter =
nullptr;
200#if __cplusplus >= 202002L
226 void onBegin()
override;
228 void onCancel()
override;
230 void onReady()
override;
Provides an awaitable that delivers a result through onReady().
Definition Coroutine.h:208
Connection Management for Signal and Slot Objects.
Definition Connectable.h:50
Multicast Signal to call multiple slots.
Definition Signal.h:190
Awaitable for async one-shot timer delay.
Definition Timer.h:212
AsyncWait(Timer &timer, std::size_t ms)
Construct an awaitable for a one-shot timer delay.
Event loop of a thread or process.
Definition EventLoop.h:83
void setActive(EventLoop &loop)
Sets the used event loop.
EventLoop * loop()
Returns the used event loop.
Definition Timer.h:96
Timer()
Default constructor.
void start(std::size_t interval)
Starts the timer.
void stop()
Stops the timer.
Signal & timeout()
Notifies about interval timeouts.
Definition Timer.h:156
std::size_t interval() const
Returns the current timer interval in milliseconds.
bool isStarted() const
Returs true if timer was started.
void detach()
Detach from used event loop.
AsyncWait waitAsync(std::size_t ms)
Start a one-shot timer delay as a C++20 awaitable.
void start(const Pt::Timespan &interval)
Starts the timer.
Represents time spans in microsecond resolution.
Definition Timespan.h:63
System programming
Definition Connection.h:26
Core module.
Definition Allocator.h:33