diff options
author | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-04-10 19:59:37 +0000 |
---|---|---|
committer | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-04-10 19:59:37 +0000 |
commit | 3df4acfa816441fc28a95dee6d0191a927145d95 (patch) | |
tree | b5ae7ca44662cfd8e5c95f1826e4406021a606f5 /java/JACE/Concurrency/Condition.java | |
parent | 60a5612b83d856fc0adc52b9f39fac9960ec9818 (diff) | |
download | ATCD-pre-subset.tar.gz |
This commit was manufactured by cvs2svn to create tag 'pre-subset'.pre-subset
Diffstat (limited to 'java/JACE/Concurrency/Condition.java')
-rw-r--r-- | java/JACE/Concurrency/Condition.java | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/java/JACE/Concurrency/Condition.java b/java/JACE/Concurrency/Condition.java deleted file mode 100644 index 1889f6e1edf..00000000000 --- a/java/JACE/Concurrency/Condition.java +++ /dev/null @@ -1,124 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Concurrency - * - * = FILENAME - * Condition.java - * - *@author Irfan Pyarali - * - *************************************************/ -package JACE.Concurrency; - -import JACE.ASX.TimeoutException; -import JACE.ASX.TimeValue; - -/** - * Abstraction for <em>traditional</em> - * condition variable - * <P> - * This condition variable allows the use of one - * mutex between multiple conditions. - * This implementation is based on the C++ version of ACE. - */ -public class Condition -{ - /** - * Default constructor - *@param Mutex for synchronization - */ - public Condition (Mutex mutex) - { - mutex_ = mutex; - } - - /** - * Wait for condition to become signaled. - *@exception InterruptedException exception during wait - */ - public void Wait () - throws InterruptedException - { - waiters_++; - - try - { - mutex_.release(); - synchronized (waitObject_) { - waitObject_.wait (); - } - mutex_.acquire (); - } - finally - { - waiters_--; - } - } - - /** - * TimedWait for condition to become signaled. Note that the - * given TimeValue is an absolute time, not a relative time. - * - *@param tv Absolute time to wait until before timing out - *@exception TimeoutException wait timed out exception - *@exception InterruptedException exception during wait - */ - public void Wait (TimeValue tv) - throws TimeoutException, InterruptedException - { - waiters_++; - - try - { - mutex_.release(); - - synchronized (waitObject_) { - long start = System.currentTimeMillis(); - long waitTime = tv.getMilliTime() - start; - if (waitTime < 1) - throw new TimeoutException (); - waitObject_.wait (waitTime); - } - - mutex_.acquire (tv); - } - finally - { - waiters_--; - } - } - - /** - * Signal condition. Wake one waiter (if any). - */ - public void signal () - { - synchronized (waitObject_) { - waitObject_.notify (); - } - } - - /** - * Signal condition. Wake up all waiters (if any). - */ - public void broadcast () - { - synchronized (waitObject_) { - waitObject_.notifyAll (); - } - } - - /** - * Accessor to lock - *@return Mutex - */ - public Mutex mutex () - { - return mutex_; - } - - private int waiters_; - private Object waitObject_ = new Object (); - private Mutex mutex_; -} |