Merge pull request #2317 from jwillemsen/jwi-deleteop
[ACE_TAO.git] / ACE / examples / C++NPv2 / Logging_Event_Handler_Ex.cpp
blob8cefebc5b9061a110dfa73c971e1c32381a9a8d8
1 /*
2 ** Copyright 2002 Addison Wesley. All Rights Reserved.
3 */
5 #include "Logging_Event_Handler_Ex.h"
6 #include "ace/Timer_Queue.h"
8 int Logging_Event_Handler_Ex::handle_input (ACE_HANDLE h) {
9 time_of_last_log_record_ =
10 reactor ()->timer_queue ()->gettimeofday ();
11 return PARENT::handle_input (h);
14 int Logging_Event_Handler_Ex::open () {
15 int result = PARENT::open ();
16 if (result != -1) {
17 ACE_Time_Value reschedule (max_client_timeout_.sec () / 4);
18 result =
19 reactor ()->schedule_timer
20 (this,
22 max_client_timeout_, // Initial timeout.
23 reschedule); // Subsequent timeouts.
25 return result;
28 int Logging_Event_Handler_Ex::handle_timeout
29 (const ACE_Time_Value &now, const void *) {
30 if (now - time_of_last_log_record_ >= max_client_timeout_)
31 reactor ()->remove_handler (this, ACE_Event_Handler::READ_MASK);
32 return 0;
35 int Logging_Event_Handler_Ex::handle_close (ACE_HANDLE,
36 ACE_Reactor_Mask) {
37 reactor ()->cancel_timer (this);
38 return PARENT::handle_close ();