diff options
author | pjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-11-12 00:53:03 +0000 |
---|---|---|
committer | pjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-11-12 00:53:03 +0000 |
commit | d34b1eeafa3fa94370d9daea349b13b3f1d2046f (patch) | |
tree | 89af770048cabc399c0d028e6dabcf43defd3170 /java/tests/ASX/TaskTest.java | |
parent | e8d6c3f71e9fc8d3d58e7d0e7cacbdd5c9737753 (diff) | |
download | ATCD-d34b1eeafa3fa94370d9daea349b13b3f1d2046f.tar.gz |
image files
test files
source files
Diffstat (limited to 'java/tests/ASX/TaskTest.java')
-rw-r--r-- | java/tests/ASX/TaskTest.java | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/java/tests/ASX/TaskTest.java b/java/tests/ASX/TaskTest.java new file mode 100644 index 00000000000..a1958f2a8dc --- /dev/null +++ b/java/tests/ASX/TaskTest.java @@ -0,0 +1,86 @@ +// ============================================================================ +// +// = PACKAGE +// tests.ASX +// +// = FILENAME +// TaskTest.java +// +// = AUTHOR +// Prashant Jain +// +// ============================================================================ +package tests.ASX; + +import java.io.*; +import ACE.OS.*; +import ACE.ASX.*; +import ACE.Reactor.*; + +public class TaskTest extends Task +{ + int nThreads_; + int nIterations_; + + public TaskTest (int nThreads, int nIterations) + { + this.nIterations_ = nIterations; + this.nThreads_ = nThreads; + if (this.activate (0, nThreads, true) == -1) + ACE.ERROR ("activate failed"); + } + + public int open (Object obj) + { + return 0; + } + + public int close (long flags) + { + return 0; + } + + public int put (MessageBlock mb, TimeValue tv) + { + return 0; + } + + public int handleTimeout (TimeValue tv, Object obj) + { + return 0; + } + + public int svc () + { + for (int i = 1; i <= this.nIterations_; i++) + { + ACE.DEBUG (Thread.currentThread ().toString () + " in iteration " + i); + // Allow other threads to run + Thread.yield (); + } + return 0; + } + + public static void main (String args[]) + { + int nThreads = 1; + int nIterations = 1; + try + { + if (args.length == 2) + { + nThreads = Integer.parseInt (args[0]); + nIterations = Integer.parseInt (args[1]); + } + else if (args.length == 1) + { + nThreads = Integer.parseInt (args[0]); + } + } + catch (NumberFormatException e) + { + ACE.ERROR ("Illegal argument."); + } + TaskTest tt = new TaskTest (nThreads, nIterations); + } +} |