Please report new issues athttps://github.com/DOCGroup
Hello, I want to use the Proactor "timer scheduling" mechanism but I have troubles with cleaning the objects upon canceling. For example I have the following: class TimerHandler : public ACE_Handler { public: TimerHandler() : ACE_Handler(), m_id(0) {} virtual ~TimerHandler(void) { } void set_id(int id) { this->m_id = id; } virtual void handle_time_out(const ACE_Time_Value&, const void *) { return ; } protected: int m_id; }; a function which is scheduling a timer: int addTimer(ACE_Time_Value atv) { TimerHandler * th = new TimerHandler(); int id = ACE_Proactor::instance()->schedule_timer(*th, 0, atv); if (id == -1) { ACE_ERROR((_TX("schedule failed"))); -1; } th->set_id(id); return id; } and another which is canceling a timer int cancelTimer(int timer_id) { if (timer_id < 0) { return -1; } int result = ACE_Proactor::instance()->cancel_timer(timer_id); return result; } The problem that I have is that the object created in addTimer is not distroyed by canceling the timer. I know that in a previous version of ACE framework it use to exists a function named "cancelled" which was called from Proactor during cancel_timer, so having in my class defined virtual int cancelled(void) { delete this; return 0; } all problems related to memory leak are unexistent. I am sure that this "cancelled" function was removed being replaced with a more inteligent mechanism of deleting the object, but unfortunately I can't figure out what is this. I am sure that is related to Auto_Ptr pattern but I do not know what is missing from my code. Best regards, Bogdan.
You're right... this was not completed in the newer proactor code. The ACE_Proactor_Handle_Timeout_Upcall::cancel_timer() method (Proactor.cpp) needs to make some sort of upcall, which will probably require a new method on ACE_Handler. Note to developers... in the Reactor framework, the ACE_Event_Handler::handle_close() hook is called with a TIMER_MASK, I believe. Check this out and see if the proactor behavior should be similar.