net.wotonomy.foundation
Class NSRecursiveLock

java.lang.Object
  extended by EDU.oswego.cs.dl.util.concurrent.ReentrantLock
      extended by net.wotonomy.foundation.NSRecursiveLock
All Implemented Interfaces:
EDU.oswego.cs.dl.util.concurrent.Sync, NSLocking

public class NSRecursiveLock
extends EDU.oswego.cs.dl.util.concurrent.ReentrantLock
implements NSLocking

A lock class that allows a thread to re-acquire it's lock recursively. Currently an API-compliance wrapper around Doug Lea's ReentrantLock, conforming to the API and behavior of com.webobjects.foundation.NSRecursiveLock.

Version:
$Revision: 893 $
Author:
cgruber@israfil.net, $Author: cgruber $

Field Summary
 
Fields inherited from class EDU.oswego.cs.dl.util.concurrent.ReentrantLock
holds_, owner_
 
Fields inherited from interface net.wotonomy.foundation.NSLocking
OneCentury, OneDay, OneHour, OneMinute, OneSecond, OneWeek, OneYear
 
Fields inherited from interface EDU.oswego.cs.dl.util.concurrent.Sync
ONE_CENTURY, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK, ONE_YEAR
 
Constructor Summary
NSRecursiveLock()
           
 
Method Summary
 void lock()
          Acquire the lock, catching the thrown exception to mirror the behavior of com.webobjects.foundation.NSRecursiveLock.
 long recursionCount()
           
 java.lang.String toString()
           
 boolean tryLock()
          Pass the buck to tryLock(long), passing zero time as the parameter.
 boolean tryLock(long milliseconds)
          Attempt to acquire the lock, catching the thrown exception to mirror the behavior of com.webobjects.foundation.NSRecursiveLock.
 boolean tryLock(NSTimestamp nstimestamp)
          Attempt to acquire a lock until the timestamp is reached.
 void unlock()
          Unlock the current lock precisely once.
 void unlock(long count)
          Unlock the current lock count times.
 
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.ReentrantLock
acquire, attempt, holds, release, release
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NSRecursiveLock

public NSRecursiveLock()
Method Detail

lock

public void lock()
Acquire the lock, catching the thrown exception to mirror the behavior of com.webobjects.foundation.NSRecursiveLock. Note that ReentrantLock.acquire() performs a notify() when it's interrupted.

Specified by:
lock in interface NSLocking
See Also:
edu.oswego.cs.dl.util.concurrent.ReentrantLock#acquire()

tryLock

public boolean tryLock()
Pass the buck to tryLock(long), passing zero time as the parameter.

See Also:
tryLock(long)

tryLock

public boolean tryLock(long milliseconds)
Attempt to acquire the lock, catching the thrown exception to mirror the behavior of com.webobjects.foundation.NSRecursiveLock. Note that ReentrantLock.attempt(*) performs a notify() when it's interrupted. Fail gracefully after the given milliseconds

Parameters:
(long) -
See Also:
edu.oswego.cs.dl.util.concurrent.ReentrantLock#acquire()

tryLock

public boolean tryLock(NSTimestamp nstimestamp)
Attempt to acquire a lock until the timestamp is reached. Add 1 to the recursion count if the calling thread already owns the lock. Otherwise block until free or until the given timestamp is reached.

See Also:
Timestamp, ReentrantLock.attempt(long);

unlock

public void unlock()
Unlock the current lock precisely once.

Specified by:
unlock in interface NSLocking

unlock

public void unlock(long count)
Unlock the current lock count times.


recursionCount

public long recursionCount()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2006 null. All Rights Reserved.