OpenTTD Source 20241224-master-gee860a5c8e
|
A timeout timer will fire once after the interval. More...
#include <timer.h>
Public Types | |
using | TPeriod = typename TTimerType::TPeriod |
using | TElapsed = typename TTimerType::TElapsed |
Public Types inherited from BaseTimer< TTimerType > | |
using | TPeriod = typename TTimerType::TPeriod |
using | TElapsed = typename TTimerType::TElapsed |
using | TStorage = typename TTimerType::TStorage |
Public Member Functions | |
TimeoutTimer (const TPeriod timeout, std::function< void()> callback, bool start=false) | |
Create a new timeout timer. | |
void | Reset () |
Reset the timer, so it will fire again after the timeout. | |
void | Reset (const TPeriod timeout) |
Reset the timer, so it will fire again after the timeout. | |
void | Abort () |
Abort the timer so it doesn't fire if it hasn't yet. | |
bool | HasFired () const |
Check whether the timeout occurred. | |
Public Member Functions inherited from BaseTimer< TTimerType > | |
BaseTimer (const TPeriod period) | |
Create a new timer. | |
virtual | ~BaseTimer () |
Delete the timer. | |
Data Fields | |
bool | fired |
Whether the timeout has occurred. | |
Data Fields inherited from BaseTimer< TTimerType > | |
TPeriod | period |
The period of the timer. | |
TStorage | storage = {} |
The storage of the timer. | |
Private Member Functions | |
void | Elapsed (TElapsed count) override |
Called by the timer manager to notify the timer that the given amount of time has elapsed. | |
void | Elapsed (TimerGameCalendar::TElapsed trigger) |
void | Elapsed (TimerGameEconomy::TElapsed trigger) |
void | Elapsed (TimerGameRealtime::TElapsed delta) |
void | Elapsed (TimerGameTick::TElapsed delta) |
Private Attributes | |
std::function< void()> | callback |
Additional Inherited Members |
A timeout timer will fire once after the interval.
You can reset it to fire again. The timer will never fire before the interval has passed, but in times of severe stress it might be late.
using TimeoutTimer< TTimerType >::TElapsed = typename TTimerType::TElapsed |
using TimeoutTimer< TTimerType >::TPeriod = typename TTimerType::TPeriod |
|
inline |
Create a new timeout timer.
By default the timeout starts aborted; you will have to call Reset() before it starts.
timeout | The timeout after which the timer will fire. |
callback | The callback to call when the timeout has passed. |
start | Whether to start the timer immediately. If false, you can call Reset() to start it. |
|
inline |
Abort the timer so it doesn't fire if it hasn't yet.
Definition at line 161 of file timer.h.
References TimeoutTimer< TTimerType >::fired.
Referenced by StatusBarWindow::OnInvalidateData(), and StartupCompanies().
|
overrideprivatevirtual |
Called by the timer manager to notify the timer that the given amount of time has elapsed.
delta | Depending on the time type, this is either in milliseconds or in ticks. |
Implements BaseTimer< TTimerType >.
|
private |
Definition at line 86 of file timer_game_calendar.cpp.
|
private |
Definition at line 113 of file timer_game_economy.cpp.
|
private |
Definition at line 41 of file timer_game_realtime.cpp.
|
private |
Definition at line 40 of file timer_game_tick.cpp.
|
inline |
Check whether the timeout occurred.
Definition at line 171 of file timer.h.
References TimeoutTimer< TTimerType >::fired.
Referenced by StatusBarWindow::DrawWidget().
|
inline |
Reset the timer, so it will fire again after the timeout.
Definition at line 140 of file timer.h.
References TimeoutTimer< TTimerType >::fired, and BaseTimer< TTimerType >::storage.
Referenced by GSConfigWindow::OnClick(), NewGRFParametersWindow::OnClick(), ScriptSettingsWindow::OnClick(), StatusBarWindow::OnInvalidateData(), MainWindow::OnResize(), MainWindow::OnScroll(), and NewGRFProfiler::StartTimer().
|
inline |
Reset the timer, so it will fire again after the timeout.
timeout | Set a new timeout for the next trigger. |
Definition at line 151 of file timer.h.
References TimerManager< TTimerType >::ChangeRegisteredTimerPeriod(), TimeoutTimer< TTimerType >::fired, and BaseTimer< TTimerType >::storage.
|
private |
bool TimeoutTimer< TTimerType >::fired |
Whether the timeout has occurred.
Definition at line 178 of file timer.h.
Referenced by TimeoutTimer< TTimerType >::Abort(), TimeoutTimer< TTimerType >::HasFired(), TimeoutTimer< TTimerType >::Reset(), and TimeoutTimer< TTimerType >::Reset().