summaryrefslogtreecommitdiffstats
path: root/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-03-18 08:12:31 +0100
committerSven Gothel <[email protected]>2013-03-18 08:12:31 +0100
commit4becdfa125b07ff969d6540e1112735b53cd15eb (patch)
treea913192eecba89cf9aed3f23edb5c26b38537c7c /src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java
parent192224fc3c38521f38eb3bc51bebb16b628e4cdb (diff)
Fix RecursiveLockImpl* corner case: Timeout reached but lock released -> Assume Lock
If timeout has been reached but the lock has been released, the lock has to be assumed.
Diffstat (limited to 'src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java')
-rw-r--r--src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java b/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java
index a26dfa4..986a7fc 100644
--- a/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java
+++ b/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java
@@ -71,12 +71,12 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
}
lockedStack = s;
}
- // lock count by same thread
+ /** lock count by same thread */
private int holdCount = 0;
- // stack trace of the lock, only used if DEBUG
- private Throwable lockedStack = null;
- // waiting thread queue
+ /** waiting thread queue */
final ArrayList<WaitingThread> queue = new ArrayList<WaitingThread>();
+ /** stack trace of the lock, only used if DEBUG */
+ private Throwable lockedStack = null;
}
private Sync sync = new Sync();
@@ -180,6 +180,9 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
if ( 0 >= timeout ) {
// locked by other thread and no waiting requested
+ if(TRACE_LOCK) {
+ System.err.println("+++ LOCK XY "+toString()+", cur "+threadName(cur)+", left "+timeout+" ms");
+ }
return false;
}
@@ -213,15 +216,12 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
}
} while ( cur != sync.getOwner() && 0 < timeout ) ;
- if( 0 >= timeout ) {
+ if( 0 >= timeout && cur != sync.getOwner() ) {
// timed out
if(!wCur.signaledByUnlock) {
sync.queue.remove(wCur); // O(n)
}
- if(cur == sync.getOwner()) {
- sync.setOwner(null);
- }
- if(TRACE_LOCK || DEBUG) {
+ if(TRACE_LOCK) {
System.err.println("+++ LOCK XX "+toString()+", cur "+threadName(cur)+", left "+timeout+" ms");
}
return false;