|
cxxitimer 2.0.5
A C++ library to handle linux interval timer
|
cxxitimer is a C++ library that provides a convenient wrapper around the Linux interval timer API (setitimer / getitimer). It exposes three timer types that map directly to the POSIX interval timers, each enforcing a single-instance-per-process constraint at runtime.
| Class | POSIX timer | Signal | Measures |
|---|---|---|---|
| cxxitimer::ITimer_Real | ITIMER_REAL | SIGALRM | Wall-clock (real) time |
| cxxitimer::ITimer_Virtual | ITIMER_VIRTUAL | SIGVTALRM | User-mode CPU time |
| cxxitimer::ITimer_Prof | ITIMER_PROF | SIGPROF | Total (user + system) CPU time |
Only one instance of each type may exist at any time. Attempting to create a second instance throws std::logic_error.
Intervals and initial values can be specified as timeval or double (seconds):
The speed factor scales the timer interval. It can be changed while the timer is running.
The timer must be stopped before changing the interval:
Timer state (interval and value) can be written to and read from binary file streams:
The library also provides arithmetic operators for timeval and itimerval (multiplication and division by a double factor), as well as conversion functions:
timeval to secondstimeval Project URL: https://gitlab.com/nikolask-cpp-libs/cxxitimer
This library is licensed under the MIT License.
Copyright (c) 2022-2026 Nikolas Koesling