Efficient Timer Algorithm

前端 未结 3 660
無奈伤痛
無奈伤痛 2021-02-04 16:04

What is the best algorithm to implement a simple timer library. The library should allow the following:

  1. Timers to be started
  2. Timers to be stopped
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-04 16:46

    Best algorithm I have seen for timers is a timer wheel found in the research paper Hashed and Hierarchical Timing Wheels: Data Structures for the Efficient Implementation of a Timer Facility

    I know in Java there is an implementation with Netty, JBoss and I am sure elsewhere too that you can use, if you are writing in Java.

提交回复
热议问题