|
libecs-cpp 2.1.0
Entity Component System library in C++
|
A repeating schedule: says when the next update is due. More...
#include <Timing.hpp>
Public Member Functions | |
| Timing (std::chrono::microseconds interval=DEFAULT_INTERVAL) | |
| Creates a schedule with the given interval, first due one full interval from now. | |
| Timing (uint32_t frequency) | |
| Creates a schedule from a bare number, which is the interval in microseconds. | |
| bool | ShouldUpdate (std::chrono::microseconds now) |
| Says whether an update is due at the given instant and, when it is, moves the schedule on. | |
| bool | ShouldUpdate () |
| Says whether an update is due now by the real steady clock and, when it is, moves the schedule on. | |
| void | Restart (std::chrono::microseconds now) |
| Starts a new schedule at the given instant: the first update is due one full interval later. | |
| void | SetInterval (std::chrono::microseconds interval) |
| Changes the interval. | |
| std::chrono::microseconds | GetInterval () const |
| Returns the interval between updates. | |
| void | SetFrequency (uint32_t frequency) |
| Changes the interval to a bare number of microseconds, without a range check. | |
| uint32_t | GetFrequency () const |
| Returns the interval in microseconds, or 4 294 967 295 if it is longer than that number can hold. | |
A repeating schedule: says when the next update is due.
The interval is the time between updates, in microseconds. A larger interval means updates happen less often. An interval of zero means due on every call. The longest interval is MAX_INTERVAL; anything below zero or above it is rejected with std::runtime_error.
A new schedule is first due one full interval after it was created (or after Restart()). When a call finds that one or more whole intervals have passed, the schedule moves forward by exactly those whole intervals, so the average rate stays exact however unevenly it is asked. If more than MAX_CATCHUP whole intervals have passed, which happens after a long stall, it fires once and starts counting again from that moment instead of catching up.
Thread: container thread only.
|
inline |
Creates a schedule with the given interval, first due one full interval from now.
Throws std::runtime_error for an interval below zero or above MAX_INTERVAL.
|
inline |
Creates a schedule from a bare number, which is the interval in microseconds.
Deprecated since 1.8.0; no removal is scheduled, and a removal will be announced in the release notes first.
|
inline |
Returns the interval in microseconds, or 4 294 967 295 if it is longer than that number can hold.
Use GetInterval() instead. Deprecated since 1.8.0; no removal is scheduled, and a removal will be announced in the release notes first.
|
inline |
Returns the interval between updates.
|
inline |
Starts a new schedule at the given instant: the first update is due one full interval later.
|
inline |
Changes the interval to a bare number of microseconds, without a range check.
Deprecated since 1.8.0; no removal is scheduled, and a removal will be announced in the release notes first.
|
inline |
Changes the interval.
The next due time carries on from the last one, so nothing is skipped and nothing bursts. Throws std::runtime_error, changing nothing, outside 0 to MAX_INTERVAL.
|
inline |
Says whether an update is due now by the real steady clock and, when it is, moves the schedule on.
|
inline |
Says whether an update is due at the given instant and, when it is, moves the schedule on.
The instant comes from the clock the caller uses; an instant earlier than the last one counts as no time having passed. An interval of zero is always due and leaves the schedule alone.