diff options
author | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-01-01 08:00:34 +0000 |
---|---|---|
committer | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-01-01 08:00:34 +0000 |
commit | d9661aebab28abc0ec4fb1e716170d347d56c168 (patch) | |
tree | ecb671ab4b8e299bf5cbb8b2dfeed8a49b65fc06 /java/tests/Concurrency/Condition/SimpleMessageQueue.java | |
parent | ea0d28240863caf437a18071bfd03e7b146c5ade (diff) | |
download | ATCD-unlabeled-4.3.2.tar.gz |
This commit was manufactured by cvs2svn to create branchunlabeled-4.3.2
'unlabeled-4.3.2'.
Diffstat (limited to 'java/tests/Concurrency/Condition/SimpleMessageQueue.java')
-rw-r--r-- | java/tests/Concurrency/Condition/SimpleMessageQueue.java | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/java/tests/Concurrency/Condition/SimpleMessageQueue.java b/java/tests/Concurrency/Condition/SimpleMessageQueue.java deleted file mode 100644 index 5bdc22c0a72..00000000000 --- a/java/tests/Concurrency/Condition/SimpleMessageQueue.java +++ /dev/null @@ -1,86 +0,0 @@ -package tests.Concurrency.Condition; - -import ACE.ASX.TimeoutException; -import ACE.ASX.TimeValue; -import ACE.Concurrency.*; - -public class SimpleMessageQueue -{ - private int num_items_ = 0; - private int head_ = 0, tail_ = 0; - private Object[] queue_; - - private Mutex lock_ = new Mutex (); - private Condition notFull_ = new Condition (lock_); - private Condition notEmpty_ = new Condition (lock_); - - public SimpleMessageQueue(int size) - { - queue_ = new Object[size]; - } - - public void enqueue(Object element, TimeValue timeout) - throws TimeoutException, InterruptedException - { - try - { - lock_.acquire (); - while (this.isFull ()) - notFull_.Wait (timeout); - - if (tail_ == queue_.length) - tail_ = 0; - queue_[tail_] = element; - tail_++; - - num_items_++; - notEmpty_.signal (); - } - finally - { - lock_.release (); - } - } - - public Object dequeue (TimeValue timeout) - throws TimeoutException, InterruptedException - { - Object return_value = null; - - try - { - lock_.acquire (); - while (this.isEmpty ()) - notEmpty_.Wait (timeout); - - return_value = queue_[head_]; - head_++; - if (head_ == queue_.length) - head_ = 0; - - num_items_--; - notFull_.signal (); - } - finally - { - lock_.release (); - } - return return_value; - } - - public boolean isEmpty() - { - return num_items_ == 0; - } - - public boolean isFull() - { - return num_items_ == queue_.length; - } - - public int size() - { - return num_items_; - } -} - |