summaryrefslogtreecommitdiff
path: root/tests/Async_Timer_Queue_Test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Async_Timer_Queue_Test.cpp')
-rw-r--r--tests/Async_Timer_Queue_Test.cpp55
1 files changed, 36 insertions, 19 deletions
diff --git a/tests/Async_Timer_Queue_Test.cpp b/tests/Async_Timer_Queue_Test.cpp
index 2c69643ae53..6a00e6869cc 100644
--- a/tests/Async_Timer_Queue_Test.cpp
+++ b/tests/Async_Timer_Queue_Test.cpp
@@ -18,20 +18,44 @@
// ============================================================================
#include "ace/Profile_Timer.h"
-#include "ace/Timer_Queue.h"
#include "ace/Timer_List.h"
-#include "ace/Timer_Heap.h"
-#include "ace/Timer_Wheel.h"
-#include "ace/Timer_Hash.h"
-#include "ace/Timer_Queue.h"
#include "test_config.h"
static int lines = 0;
+static ACE_Timer_List timer_list;
+
static void
-handler (int i)
+handler (int signum)
+{
+ switch (signum)
+ {
+ case SIGALRM:
+ ACE_DEBUG ((LM_DEBUG, "you've entered %d lines, time = %d\n", lines, ACE_OS::time ()));
+ break;
+ case SIGINT:
+ ACE_DEBUG ((LM_DEBUG, "dumping timer queue\n"));
+ {
+ for (ACE_Timer_List_Iterator iter (timer_list);
+ iter.isdone () == 0;
+ iter.next ())
+ iter.item ()->dump ();
+ }
+ break;
+ }
+}
+
+static char menu[] =
+"****\n"
+"1) schedule_timer usecs \n"
+"2) cancel_timer timer_id\n"
+"^C list_timers\n"
+"please enter your choice: ";
+
+static void
+parse_buf (char *buf)
{
- fprintf (stderr, "you've entered %d lines, time = %d\n", lines, time (0));
+ ACE_DEBUG ((LM_DEBUG, "===== %s", buf));
}
/* sigprocmask (SIG_BLOCK, &ss, 0);
@@ -45,30 +69,23 @@ run (u_int delay)
ACE_OS::ualarm (delay, delay);
- ACE_DEBUG ((LM_DEBUG,
- "****\n"
- "1) schedule_timer usecs \n"
- "2) cancel_timer timer_id\n"
- "^C list_timers\n"
- "please enter your choice: "));
+ ACE_DEBUG ((LM_DEBUG, "%s", menu));
for (;;)
{
char buf[BUFSIZ];
errno = 0;
- if (fgets (buf, sizeof buf, stdin) == 0)
+ if (ACE_OS::fgets (buf, sizeof buf, stdin) == 0)
{
- fprintf (stderr, "errno = %d\n", errno);
-
if (errno != EINTR)
break;
}
else
{
- fprintf (stderr, "buf = %s\n", buf);
lines++;
- fprintf (stderr, "please enter your choice: ");
+ parse_buf (buf);
+ ACE_DEBUG ((LM_DEBUG, "%s", menu));
}
}
@@ -80,7 +97,7 @@ main (int argc, char *argv[])
{
// ACE_START_TEST ("Timer_Queue_Test");
- u_int delay = argc > 1 ? atoi (argv[1]) : 1000;
+ u_int delay = argc > 1 ? atoi (argv[1]) : ACE_DEFAULT_USECS;
run (delay);