diff options
author | mcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2011-12-15 11:09:41 +0000 |
---|---|---|
committer | mcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2011-12-15 11:09:41 +0000 |
commit | 9d1004206324867a4287e99b9675d24e536fa090 (patch) | |
tree | 89d59383f294627917ee3cf054f347884a914f32 /ACE/ace/Event_Handler_Handle_Timeout_Upcall.cpp | |
parent | b8d69007a4e25977f11cc3de8eb3793c0c61161a (diff) | |
download | ATCD-9d1004206324867a4287e99b9675d24e536fa090.tar.gz |
Thu Dec 15 11:00:00 UTC 2011 Martin Corino <mcorino@remedy.nl>
Merged timer_policy branch.
Diffstat (limited to 'ACE/ace/Event_Handler_Handle_Timeout_Upcall.cpp')
-rw-r--r-- | ACE/ace/Event_Handler_Handle_Timeout_Upcall.cpp | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/ACE/ace/Event_Handler_Handle_Timeout_Upcall.cpp b/ACE/ace/Event_Handler_Handle_Timeout_Upcall.cpp new file mode 100644 index 00000000000..17ab1e04da2 --- /dev/null +++ b/ACE/ace/Event_Handler_Handle_Timeout_Upcall.cpp @@ -0,0 +1,98 @@ +// $Id$ + +#include "ace/Event_Handler_Handle_Timeout_Upcall.h" +#include "ace/Reactor_Timer_Interface.h" +#include "ace/Abstract_Timer_Queue.h" + +#if !defined(__ACE_INLINE__) +# include "ace/Event_Handler_Handle_Timeout_Upcall.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Event_Handler_Handle_Timeout_Upcall:: +ACE_Event_Handler_Handle_Timeout_Upcall (void) +{ +} + +ACE_Event_Handler_Handle_Timeout_Upcall:: +~ACE_Event_Handler_Handle_Timeout_Upcall (void) +{ +} + +int +ACE_Event_Handler_Handle_Timeout_Upcall:: +timeout (ACE_Timer_Queue &timer_queue, + ACE_Event_Handler *event_handler, + const void *act, + int recurring_timer, + const ACE_Time_Value &cur_time) +{ + int requires_reference_counting = 0; + + if (!recurring_timer) + { + requires_reference_counting = + event_handler->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + } + + // Upcall to the <handler>s handle_timeout method. + if (event_handler->handle_timeout (cur_time, act) == -1) + { + if (event_handler->reactor_timer_interface ()) + event_handler->reactor_timer_interface ()->cancel_timer (event_handler, 0); + else + timer_queue.cancel (event_handler, 0); // 0 means "call handle_close()". + } + + if (!recurring_timer && + requires_reference_counting) + { + event_handler->remove_reference (); + } + + return 0; +} + +int +ACE_Event_Handler_Handle_Timeout_Upcall:: +cancel_type (ACE_Timer_Queue &, + ACE_Event_Handler *event_handler, + int dont_call, + int &requires_reference_counting) +{ + requires_reference_counting = + event_handler->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + + // Upcall to the <handler>s handle_close method + if (dont_call == 0) + event_handler->handle_close (ACE_INVALID_HANDLE, + ACE_Event_Handler::TIMER_MASK); + + return 0; +} + +int +ACE_Event_Handler_Handle_Timeout_Upcall:: +deletion (ACE_Timer_Queue &timer_queue, + ACE_Event_Handler *event_handler, + const void *) +{ + int requires_reference_counting = 0; + + this->cancel_type (timer_queue, + event_handler, + 0, + requires_reference_counting); + + this->cancel_timer (timer_queue, + event_handler, + 0, + requires_reference_counting); + + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL |