summaryrefslogtreecommitdiff
path: root/tests/Reactor_Timer_Test.cpp
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1996-10-29 07:40:16 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1996-10-29 07:40:16 +0000
commit5036e0a0f727dd809b932b41dda3989c0f47e2fd (patch)
treeaf7834a0f9e9046c65f6260a03a8a58cca7c7f5b /tests/Reactor_Timer_Test.cpp
parent60aa7663705dd9338f66fb28384e8b31900434bb (diff)
downloadATCD-5036e0a0f727dd809b932b41dda3989c0f47e2fd.tar.gz
Jamming
Diffstat (limited to 'tests/Reactor_Timer_Test.cpp')
-rw-r--r--tests/Reactor_Timer_Test.cpp53
1 files changed, 32 insertions, 21 deletions
diff --git a/tests/Reactor_Timer_Test.cpp b/tests/Reactor_Timer_Test.cpp
index 72c0674281c..fe2a1aff668 100644
--- a/tests/Reactor_Timer_Test.cpp
+++ b/tests/Reactor_Timer_Test.cpp
@@ -31,60 +31,71 @@ static int odd = 0;
class Reactor_Timer : public ACE_Event_Handler
{
public:
- virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg)
+ virtual int handle_timeout (const ACE_Time_Value &tv,
+ const void *arg)
{
- ACE_ASSERT ((int) arg == count);
- if (odd == 1)
- count += 2;
- else
- count += 1;
- ACE_DEBUG ((LM_DEBUG, "%d: Timer #%d timed out!\n", count, int (arg)));
- if ((int) arg == ACE_MAX_TIMERS - 1)
+ int current_count = int (arg);
+ ACE_ASSERT (current_count == count);
+
+ ACE_DEBUG ((LM_DEBUG, "%d: Timer #%d timed out at %d!\n",
+ count, current_count, tv.sec ()));
+
+ count += (1 + odd);
+
+ if (current_count == ACE_MAX_TIMERS - 1)
done = 1;
+
return 0;
}
-
-private:
};
int
-main (int argc, char *argv[])
+main (int, char *argv[])
{
ACE_START_TEST;
ACE_Reactor reactor;
+
Reactor_Timer rt[ACE_MAX_TIMERS];
int t_id[ACE_MAX_TIMERS];
int i;
for (i = 0; i < ACE_MAX_TIMERS; i++)
- {
- t_id[i] = reactor.schedule_timer (&(rt[i]), (const void *) i, ACE_Time_Value (2 * i + 1));
- }
+ t_id[i] = reactor.schedule_timer (&rt[i],
+ (const void *) i,
+ ACE_Time_Value (2 * i + 1));
+
while (!done)
reactor.handle_events ();
done = 0;
count = 0;
- // Now try multiple timers for ONE event handler (should produce the same result)
+ // Now try multiple timers for ONE event handler (should produce the
+ // same result).
for (i = 0; i < ACE_MAX_TIMERS; i++)
- {
- t_id[i] = reactor.schedule_timer (&(rt[0]), (const void *) i, ACE_Time_Value (2 * i + 1));
- }
+ t_id[i] = reactor.schedule_timer (&rt[0],
+ (const void *) i,
+ ACE_Time_Value (2 * i + 1));
+
while (!done)
reactor.handle_events ();
done = 0;
count = 1;
odd = 1;
- // Cancel even numbered timers
+
for (i = 0; i < ACE_MAX_TIMERS; i++)
{
- t_id[i] = reactor.schedule_timer (&(rt[0]), (const void *) i, ACE_Time_Value (2 * i + 1));
- if (((i+2) % 2) == 0)
+ t_id[i] = reactor.schedule_timer (&rt[0],
+ (const void *) i,
+ ACE_Time_Value (2 * i + 1));
+
+ // Cancel even numbered timers.
+ if (ACE_EVEN (i))
reactor.cancel_timer (t_id[i]);
}
+
while (!done)
reactor.handle_events ();