实现简单计时器库的最佳算法是什么?该库应允许以下内容:
在计时器到期时,将调用回调函数
计时器模块将允许计时器具有Ns的时间分辨率,并且每Ns将给模块一个踢,以提示模块检查过期的计时器。 / p>
许多计时器可能同时处于活动状态。
最好的算法需要满足以下目标
问候
解决方案我看到的关于计时器的最佳算法是研究论文哈希和分层定时轮:用于高效实现计时器功能的数据结构
我知道在Java中有Netty,JBoss的实现,而且我敢肯定,如果您使用Java编写,也可以在其他地方使用。
What is the best algorithm to implement a simple timer library. The library should allow the following:
On Timer expiry a callback function will be called.
The timer module will allow timers to have a time resolution of Ns and the module shall be given a kick every Ns to prompt the module to check for expired timers.
Many timers may be simultaneously active.
The best algorithm needs to meet the following goals
Regards
解决方案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.
更多推荐
高效定时器算法
发布评论