muduo库 TimerQueue 分析

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/andylau00j/article/details/80904180



定时器  时序图


对于定时任务的原理:

  1. muduo采用timerfd_*将超时任务转换成文件描述符进行监听
  2. 当时间一到,timerfd变为可读,相应的Channel调用回调函数(TimerQueue::handleRead
  3. 回调函数中将所有在TimerQueue中的超时任务找出,一次调用其回调函数
  4. 对于周期性定时任务,再添加回TimerQueue








猜你喜欢

转载自blog.csdn.net/andylau00j/article/details/80904180