[英]Why should I use my own TimerQueue when I can use the default one?
What advantages do I have from making my own TimerQueue
by calling CreateTimerQueue
and using it rather than just calling CreateTimerQueueTimer
with a NULL
value for TimerQueue
and thus using the default one? 通过调用
CreateTimerQueue
并使用它而不是仅使用CreateTimerQueueTimer
的NULL
值调用TimerQueue
并因此使用默认值,我可以通过创建自己的TimerQueue
有什么优势? I understand that if I use my own I can delete all the timers at once by deleting the queue. 我知道如果我使用自己的,我可以通过删除队列一次删除所有的计时器。 I can hardly imagine that this is the only advantage, what am I missing?
我很难想象这是唯一的优势,我错过了什么?
First thanks to HerrJoebob and Raymond Chen for their quality comments. 首先感谢HerrJoebob和Raymond Chen的质量评论。 I did not originally intend to answer my own question.
我原本打算不回答我自己的问题。
Reason 1: someone else deleting all timers in the default queue (thanks to HerrJoebob) 原因1:其他人删除默认队列中的所有计时器(感谢HerrJoebob)
Reason 2: someone else putting a 'bajillion' (slang for very many) timers in the default queue and starving yours (thanks to Raymond Chen) 原因2:其他人将“bajillion”(俚语为很多)计时器放入默认队列并让你们挨饿(感谢Raymond Chen)
Reason 3: using the flag WT_EXECUTEINTIMERTHREAD
saves a context switch when executing the callback, however if the callback takes a while it delays other timers. 原因3:使用标志
WT_EXECUTEINTIMERTHREAD
在执行回调时保存上下文切换,但是如果回调需要一段时间,则会延迟其他定时器。 Using your own TimerQueue means you have your own timer thread so no one else can delay your timers and you can't inadvertently delay someone else's. 使用你自己的TimerQueue意味着你有自己的计时器线程,所以没有其他人可以延迟你的计时器,你不能无意中推迟别人的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.