blob: 38f098c1bb7c16cb4067c5286b6935e1fd25f762 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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);
}
}
}
|