2 #include "ace/Service_Config.h"
3 #include "ace/Get_Opt.h"
4 #include "ace/OS_NS_stdio.h"
5 #include "ace/OS_NS_string.h"
6 #include "ace/Truncate.h"
9 Handle_Timeout::Handle_Timeout () : count (0)
14 Handle_Timeout::info (ACE_TCHAR **strp, size_t length) const
16 ACE_TCHAR buf[BUFSIZ];
18 ACE_OS::strcpy (buf, ACE_TEXT("# tests timeout facility\n"));
20 if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
26 ACE_OS::strncpy (*strp, buf, length);
29 return ACE_Utils::truncate_cast<int> (ACE_OS::strlen (buf));
33 Handle_Timeout::init (int argc, ACE_TCHAR *argv[])
35 ACE_Time_Value delta (10);
36 ACE_Time_Value interval (1);
37 ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("a:d:i:"), 0);
40 for (int c; (c = get_opt ()) != -1; )
44 delta.sec (ACE_OS::atoi (get_opt.opt_arg ()));
47 interval.sec (ACE_OS::atoi (get_opt.opt_arg ()));
50 arg = ACE_OS::atoi (get_opt.opt_arg ());
56 if (ACE_Reactor::instance ()->schedule_timer (this,
57 reinterpret_cast<void *> (arg),
66 Handle_Timeout::fini ()
72 Handle_Timeout::get_handle () const
74 return ACE_INVALID_HANDLE;
78 Handle_Timeout::handle_timeout (const ACE_Time_Value &tv,
81 if (this->count++ >= 10)
82 return -1; // Automatically cancel periodic timer...
84 // Cast arg to a long, first, because a pointer is the same
85 // size as a long on all current ACE platforms.
87 ACE_TEXT ("time for this(%u) expired at (%d, %d) with arg = %d\n"),
91 (int) (ptrdiff_t) arg));