Is ACE reactor timer managment thread safe?

Posted by idimba on Stack Overflow See other posts from Stack Overflow or by idimba
Published on 2010-01-18T21:12:54Z Indexed on 2010/03/21 4:01 UTC
Read the original article Hit count: 490

Filed under:
|
|

I have a module that manages timers in my aplication. This class has basibly three functions:

Instance of ACE_Reactor is used internally by the module to manage the timers.

  • schedule timer - calls ACE_Reactor::schedule_timer(). One of the arguments is a callback, called upon timer experation.
  • cancel timer - calls ACE_Reactor::cancel_timer()

The reactor executed in private timer of execution, so schedule/cancel and timeout callback are executed in different threads.

ACE_Reactor::schedule_timer() receives a heap allocatec structure ( arg argument).

This structure later deleted when canceling timer or when timeout handler is called. But since cancel and timeout handler are executed in different threads it looks like there's cases that the structure is deleted twice.

Isn't it responsibility of reactor to ensure that timer is canceled when timeout handler is called?

© Stack Overflow or respective owner

Related posts about c++

Related posts about ace