summaryrefslogtreecommitdiff
path: root/java/JACE/tests/ASX/MessageQueueTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/JACE/tests/ASX/MessageQueueTest.java')
-rw-r--r--java/JACE/tests/ASX/MessageQueueTest.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/java/JACE/tests/ASX/MessageQueueTest.java b/java/JACE/tests/ASX/MessageQueueTest.java
new file mode 100644
index 00000000000..38f098c1bb7
--- /dev/null
+++ b/java/JACE/tests/ASX/MessageQueueTest.java
@@ -0,0 +1,54 @@
+// ============================================================================
+//
+// = PACKAGE
+// tests.ASX
+//
+// = FILENAME
+// MessageQueueTest.java
+//
+// = AUTHOR
+// Prashant Jain
+//
+// ============================================================================
+package JACE.tests.ASX;
+
+import java.io.*;
+import JACE.OS.*;
+import JACE.ASX.*;
+
+public class MessageQueueTest
+{
+ public static void main (String args[])
+ {
+ ACE.enableDebugging ();
+
+ try
+ {
+ MessageBlock conMb;
+ MessageQueue msgQueue = new MessageQueue ();
+ MessageBlock mb1 = new MessageBlock ("hello");
+ MessageBlock mb2 = new MessageBlock ("world");
+ mb1.msgPriority (5);
+ mb2.msgPriority (7);
+
+ // Enqueue in priority order.
+ if (msgQueue.enqueue (mb1) == -1)
+ ACE.ERROR ("put_next");
+
+ if (msgQueue.enqueue (mb2) == -1)
+ ACE.ERROR ("put_next");
+
+ // Now try to dequeue
+ if ((conMb = msgQueue.dequeueHead ()) == null)
+ ACE.ERROR ("dequeueHead");
+ else
+ ACE.DEBUG ("Consumer: removed item " + conMb.base ()
+ + " of priority " + conMb.msgPriority ());
+ }
+ catch (InterruptedException e)
+ {
+ ACE.ERROR (e);
+ }
+ }
+}
+