我有使用 SetWaitableTimer 的遗留代码在午夜后 10 秒执行一些任务。
SetWaitableTimer
具有以下功能,在代码中使用:
If the system time is adjusted, the due time of any outstanding absolute timers is adjusted.
我正在将代码移植到 gcc/Linux。我如何模拟上述行为?
最佳答案
This是对 Linux 定时器功能的一个很好的概述。你想要 timer_create()
/ timer_delete()
CLOCK_REALTIME
系列,然后是 timer_settime()
使用 TIMER_ABSTIME
。根据this FAQ如果系统时钟发生变化,应该进行调整,但我从未测试过。
关于linux - 将 VC++ SetWaitableTimer 移植到 gcc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4620166/