diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java | 18 | ||||
-rw-r--r-- | src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java | 18 |
2 files changed, 20 insertions, 16 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; diff --git a/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java b/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java index 5b5e42e..e8fecb1 100644 --- a/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java +++ b/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java @@ -107,11 +107,12 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { @Override public final void decrQSz() { qsz--; } - // lock count by same thread - private int holdCount = 0; - // stack trace of the lock, only used if DEBUG - private Throwable lockedStack = null; + /** lock count by same thread */ + private int holdCount = 0; + /** queue size of waiting threads */ private int qsz = 0; + /** stack trace of the lock, only used if DEBUG */ + private Throwable lockedStack = null; } protected final Sync sync; @@ -207,7 +208,7 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { synchronized(sync) { final Thread cur = Thread.currentThread(); if(TRACE_LOCK) { - System.err.println("+++ LOCK 0 "+toString()+", cur "+threadName(cur)); + System.err.println("+++ LOCK 0 "+toString()+", timeout "+timeout+" ms, cur "+threadName(cur)); } if (sync.isOwner(cur)) { sync.incrHoldCount(cur); @@ -221,6 +222,9 @@ public class RecursiveLockImpl01Unfairish 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; } @@ -232,9 +236,9 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { } while (null != sync.getOwner() && 0 < timeout) ; sync.decrQSz(); - if( 0 >= timeout ) { + if( 0 >= timeout && sync.getOwner() != null ) { // timed out - if(TRACE_LOCK || DEBUG) { + if(TRACE_LOCK) { System.err.println("+++ LOCK XX "+toString()+", cur "+threadName(cur)+", left "+timeout+" ms"); } return false; |