What is the easiest, most effective way in C on Linux to asynchronously call a function after a certain delay (like JavaScript’s setTimeout) or set a repetitive timer call it periodically (similar to setInterval)?
Though this question applies to Linux, I hope there is a method that is cross-platform.
The simplest Linux specific solution is to use the
alarmfunction:getitimerandsetitimerfunctions can be used to create timers with higher-precisions. (more…).