I\'m looking to implement a simple timer mechanism in C++. The code should work in Windows and Linux. The resolution should be as precise as possible (at least millisecond a
I have seen this implemented a few times as closed-source in-house solutions .... which all resorted to #ifdef
solutions around native Windows hi-res timers on the one hand and Linux kernel timers using struct timeval
(see man timeradd
) on the other hand.
You can abstract this and a few Open Source projects have done it -- the last one I looked at was the CoinOR class CoinTimer but there are surely more of them.