diff options
author | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-12-30 06:50:29 +0000 |
---|---|---|
committer | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-12-30 06:50:29 +0000 |
commit | a4a7690c336d4c8a16b3041c86d501ba38226e96 (patch) | |
tree | 9e9f93a98edd2591453f092d178ad29a1c5fb519 /java/src/Condition.java | |
parent | a5c4d8047ab58df5c45092e18ae503ad40518f0e (diff) | |
download | ATCD-unlabeled-4.1.2.tar.gz |
This commit was manufactured by cvs2svn to create branchunlabeled-4.1.2
'unlabeled-4.1.2'.
Diffstat (limited to 'java/src/Condition.java')
-rw-r--r-- | java/src/Condition.java | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/java/src/Condition.java b/java/src/Condition.java deleted file mode 100644 index 17acf228346..00000000000 --- a/java/src/Condition.java +++ /dev/null @@ -1,124 +0,0 @@ -/************************************************* - * - * = PACKAGE - * ACE.Concurrency - * - * = FILENAME - * Condition.java - * - *@author Irfan Pyarali - * - *************************************************/ -package ACE.Concurrency; - -import ACE.ASX.TimeoutException; -import ACE.ASX.TimeValue; - -/** - * <hr> - * <h2>TITLE</h2> - *<blockquote> - * Abstraction for <em>traditional</em> - * condition variable - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * This condition variable allows the use of one - * mutex between multiple conditions. - * This implementation is based on the C++ version of ACE. - *</blockquote> - */ -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(); - semaphore_.acquire (); - mutex_.acquire (); - } - finally - { - waiters_--; - } - } - - /** - * TimedWait for condition to become signaled. - *@exception TimeoutException wait timed out exception - *@exception InterruptedException exception during wait - */ - public void Wait (TimeValue tv) - throws TimeoutException, InterruptedException - { - waiters_++; - - try - { - mutex_.release(); - - TimeValue start = TimeValue.getTimeOfDay (); - - semaphore_.acquire (tv); - - TimeValue now = TimeValue.getTimeOfDay (); - tv.minusEquals (TimeValue.minus (now, start)); - - mutex_.acquire (tv); - } - finally - { - waiters_--; - } - } - - /** - * Signal condition. Wake one waiter (if any). - */ - public void signal () - { - if (waiters_ > 0) - semaphore_.release (); - } - - /** - * Signal condition. Wake up all waiters (if any). - */ - public void broadcast () - { - for (int i = waiters_; i > 0; i--) - semaphore_.release (); - } - - /** - * Accessor to lock - *@return Mutex - */ - public Mutex mutex () - { - return mutex_; - } - - private int waiters_; - private Semaphore semaphore_ = new Semaphore (0); - private Mutex mutex_; - -} |