diff options
author | pjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-11-24 00:00:50 +0000 |
---|---|---|
committer | pjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-11-24 00:00:50 +0000 |
commit | 25a3ee5192531b1eba199f3a035e3efda77b28d7 (patch) | |
tree | 7d91e1d2c9f79c3be853940dbc120100a4d6cfaa /java/tests | |
parent | 938238d938dc1e12c2e098ac282cc4e3e605536c (diff) | |
download | ATCD-25a3ee5192531b1eba199f3a035e3efda77b28d7.tar.gz |
New test for TimerQueue
Diffstat (limited to 'java/tests')
-rw-r--r-- | java/tests/Reactor/TimerQueueTest.java | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/java/tests/Reactor/TimerQueueTest.java b/java/tests/Reactor/TimerQueueTest.java new file mode 100644 index 00000000000..de905a66aca --- /dev/null +++ b/java/tests/Reactor/TimerQueueTest.java @@ -0,0 +1,79 @@ +// ============================================================================ +// +// = PACKAGE +// tests.Reactor +// +// = FILENAME +// TimerQueueTest.java +// +// = AUTHOR +// Prashant Jain +// +// ============================================================================ +package tests.Reactor; + +import ACE.OS.*; +import ACE.ASX.*; +import ACE.Reactor.*; + +public class TimerQueueTest implements EventHandler +{ + public int handleTimeout (TimeValue tv, Object obj) + { + ACE.DEBUG ("handleTimeout: " + tv.toString () + " " + (String) obj); + return 0; + } + + public static void main (String args []) + { + TimerQueue tq = new TimerQueue (); + TimerQueueTest th1 = new TimerQueueTest (); + int n = 5; + + try + { + if (args.length == 1) + { + n = Integer.parseInt (args[0]); + } + } + catch (NumberFormatException e) + { + ACE.ERROR ("Illegal argument."); + } + + // Set a periodic timer + int id= tq.scheduleTimer (th1, + "periodic", + new TimeValue (2), + new TimeValue (3)); + + int i; + // Set a bunch of single timers + for (i=1; i < n; i++) + { + tq.scheduleTimer (th1, + "A-timer-" + new Integer (i), + new TimeValue (i*2)); + } + + TimerQueueTest th2 = new TimerQueueTest (); + for (i=1; i < n; i++) + { + tq.scheduleTimer (th2, + "B-timer-" + new Integer (i), + new TimeValue (i*3)); + } + // Cancel all timers associated with this handler + tq.cancelTimer (th2); + + try + { + Thread.sleep (30000); + } + catch (InterruptedException e) + { + } + tq.cancelTimer (id); + } +} |