Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果通过以下方式安排了一次性计时器
schedule_timer(timer,0,ACE_Time_Value(delay),ACE_Time_Value::zero)
是否需要 cancel_timer 以避免内存泄漏?
我认为答案是“视情况而定”。除了相对古老的 ACE 版本,您可以让 Reactor(或 Timer_Queue)增加事件处理程序的引用计数,并在事件处理程序从 Reactor(或 Timer_Queue)中删除时减少它。请注意,引用计数是可选,必须启用。
另外,这玩意我没用过,看文档测试!
定时器对象不会被ACE释放,但是ACE需要维护定时器的任何数据结构都会在定时器运行后被释放。
两种验证方式: