diff options
Diffstat (limited to 'projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSLock.java')
| -rw-r--r-- | projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSLock.java | 123 |
1 files changed, 58 insertions, 65 deletions
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSLock.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSLock.java index e6a5147..45afdde 100644 --- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSLock.java +++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSLock.java @@ -24,85 +24,78 @@ package net.wotonomy.foundation; import EDU.oswego.cs.dl.util.concurrent.Mutex; /** -* A simple mutually-exclusive lock. Currently an API-compliance -* subclass of an external Mutex class, conforming to the API and -* behavior of com.webobjects.foundation.NSLock. This class implements -* the NSLocking protocol (interface), and is implemented using -* Doug Lea's concurrent programming package. -* -* @author cgruber@israfil.net -* @author $Author: cgruber $ -* @version $Revision: 893 $ -* -*/ + * A simple mutually-exclusive lock. Currently an API-compliance subclass of an + * external Mutex class, conforming to the API and behavior of + * com.webobjects.foundation.NSLock. This class implements the NSLocking + * protocol (interface), and is implemented using Doug Lea's concurrent + * programming package. + * + * @author cgruber@israfil.net + * @author $Author: cgruber $ + * @version $Revision: 893 $ + * + */ public class NSLock extends Mutex implements NSLocking { - - public NSLock() { - } - - public synchronized void lock() { - try { - acquire(); - } catch (InterruptedException interruptedexception) { - notify(); - } - } - - public synchronized void unlock() { - release(); - } - - public synchronized boolean tryLock() { - return tryLock(0); - } - - public synchronized boolean tryLock(long l) { - try { - return attempt(l); - } catch (InterruptedException interruptedexception) { - notify(); - return false; - } - } - - public boolean tryLock(NSTimestamp nstimestamp) { - return tryLock(nstimestamp.getTime() - System.currentTimeMillis()); - } - - public String toString() { + public NSLock() { + } + + public synchronized void lock() { + try { + acquire(); + } catch (InterruptedException interruptedexception) { + notify(); + } + } + + public synchronized void unlock() { + release(); + } + + public synchronized boolean tryLock() { + return tryLock(0); + } + + public synchronized boolean tryLock(long l) { + try { + return attempt(l); + } catch (InterruptedException interruptedexception) { + notify(); + return false; + } + } + + public boolean tryLock(NSTimestamp nstimestamp) { + return tryLock(nstimestamp.getTime() - System.currentTimeMillis()); + } + + public String toString() { return getClass().getName() + " <" + (inuse_ ? "Locked" : "Unlocked") + ">"; - } + } - public synchronized boolean isLocked() { + public synchronized boolean isLocked() { return inuse_; - } + } } /* - * $Log$ - * Revision 1.2 2006/02/16 13:15:00 cgruber - * Check in all sources in eclipse-friendly maven-enabled packages. + * $Log$ Revision 1.2 2006/02/16 13:15:00 cgruber Check in all sources in + * eclipse-friendly maven-enabled packages. * - * Revision 1.1 2002/07/14 21:56:16 mpowers - * Contributions from cgruber. + * Revision 1.1 2002/07/14 21:56:16 mpowers Contributions from cgruber. * - * Revision 1.4 2002/06/25 19:03:02 cgruber - * Internal documentation fixes. + * Revision 1.4 2002/06/25 19:03:02 cgruber Internal documentation fixes. * - * Revision 1.3 2002/06/25 18:52:56 cgruber - * Fix javadocs that resulted from bad cut-and-paste of the - * boilerplate. + * Revision 1.3 2002/06/25 18:52:56 cgruber Fix javadocs that resulted from bad + * cut-and-paste of the boilerplate. * - * Revision 1.2 2002/06/25 17:45:52 cgruber - * Add implementation of NSLock using Doug Lea's concurrent - * programming APIs. + * Revision 1.2 2002/06/25 17:45:52 cgruber Add implementation of NSLock using + * Doug Lea's concurrent programming APIs. * - * Revision 1.1 2002/06/25 07:52:57 cgruber - * Add quite a few abstract classes, interfaces, and classes. All - * API consistent with WebObjects, but with no implementation, nor - * any private or package access members from the original. + * Revision 1.1 2002/06/25 07:52:57 cgruber Add quite a few abstract classes, + * interfaces, and classes. All API consistent with WebObjects, but with no + * implementation, nor any private or package access members from the original. * */ |
