|
RADLib
RADical C++ application framework
|
High-precision timer that emits timeout through a RADCore EventLoop. More...
#include <RADCore.h>
Inheritance diagram for RADCore::Timer:
Collaboration diagram for RADCore::Timer:Public Member Functions | |
| Timer () | |
| Creates an inactive timer. More... | |
| ~Timer () | |
| Stops the timer if active. More... | |
| void | start (int intervalMs, EventLoop &targetLoop) |
| Starts the timer with intervalMs and posts timeout to targetLoop. More... | |
| void | start (EventLoop &targetLoop) |
| Starts the timer using the previously configured interval. More... | |
| void | stop () |
| Stops the timer. More... | |
| void | setInterval (int intervalMs) |
| Sets timer interval in milliseconds. More... | |
| int | interval () const |
| Returns timer interval in milliseconds. More... | |
| bool | isActive () const |
| Returns true while the timer is active. More... | |
Public Member Functions inherited from RADCore::RADObject | |
| RADObject () | |
| Creates a RADObject bound to the current thread. More... | |
| virtual | ~RADObject () |
| Disconnects tracked event links and releases lifetime token. More... | |
| void | registerLink (const ConnectionRecord &record) |
| Registers a connection for cleanup when this object is destroyed. More... | |
| std::thread::id | threadId () const |
| Returns the thread id this object is currently associated with. More... | |
| EventLoop * | associatedEventLoop () const |
| Returns the associated event loop, if any. More... | |
| ThreadAffinity | threadAffinity () const |
| Returns both thread id and associated loop atomically. More... | |
| std::weak_ptr< void > | lifetimeToken () const |
| Returns a weak token used to drop queued callbacks after destruction. More... | |
| void | moveToThread (std::thread::id tId, EventLoop *loop=nullptr) |
| Moves the object's affinity to tId and optional loop. More... | |
Static Public Member Functions | |
| static void | singleShot (int intervalMs, EventLoop &targetLoop, EventLoop::Task task) |
| Posts task once after intervalMs milliseconds. More... | |
Public Attributes | |
| RADCore::Event< void() > | timeout |
| Raised each time the timer interval expires. More... | |
| RADCore::Event< void(std::string) > | errorOccurred |
| Raised when the timer cannot be configured or started. More... | |
| RADCore::Timer::Timer | ( | ) |
Creates an inactive timer.
| RADCore::Timer::~Timer | ( | ) |
Stops the timer if active.
| int RADCore::Timer::interval | ( | ) | const |
Returns timer interval in milliseconds.
| bool RADCore::Timer::isActive | ( | ) | const |
Returns true while the timer is active.
| void RADCore::Timer::setInterval | ( | int | intervalMs | ) |
Sets timer interval in milliseconds.
|
static |
Posts task once after intervalMs milliseconds.
| void RADCore::Timer::start | ( | EventLoop & | targetLoop | ) |
Starts the timer using the previously configured interval.
| void RADCore::Timer::start | ( | int | intervalMs, |
| EventLoop & | targetLoop | ||
| ) |
Starts the timer with intervalMs and posts timeout to targetLoop.
| void RADCore::Timer::stop | ( | ) |
Stops the timer.
| RADCore::Event<void (std::string) > RADCore::Timer::errorOccurred |
Raised when the timer cannot be configured or started.
| RADCore::Event<void () > RADCore::Timer::timeout |
Raised each time the timer interval expires.