diff options
author | Sven Gothel <[email protected]> | 2012-06-27 04:18:53 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-06-27 04:18:53 +0200 |
commit | 834b9e530e652b7ff7c5e222720bce3ad2b11c5f (patch) | |
tree | bac459da1a84abec07f70f74204a4e1deca1d226 /src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java | |
parent | 9a71703904ebfec343fb2c7266343d37a2e4c3db (diff) |
Lock Cleanup (API Change)
- LockExt -> ThreadLock - clarifying semantics (API Change)
- ThreadLock: Remove isOwner(), use isOwner(Thread.currentThread)
- adding @Override
Diffstat (limited to 'src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java')
-rw-r--r-- | src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java b/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java index c1a74fc..a26dfa4 100644 --- a/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java +++ b/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java @@ -94,42 +94,43 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock { } } + @Override public final Thread getOwner() { synchronized(sync) { return sync.getOwner(); } } - public final boolean isOwner() { - synchronized(sync) { - return isOwner(Thread.currentThread()); - } - } - + @Override public final boolean isOwner(Thread thread) { synchronized(sync) { return sync.getOwner() == thread ; } } + @Override public final boolean isLocked() { synchronized(sync) { return null != sync.getOwner(); } } + @Override public final boolean isLockedByOtherThread() { synchronized(sync) { - return null != sync.getOwner() && Thread.currentThread() != sync.getOwner() ; + final Thread o = sync.getOwner(); + return null != o && Thread.currentThread() != o ; } } + @Override public final int getHoldCount() { synchronized(sync) { return sync.holdCount; } } + @Override public final void validateLocked() throws RuntimeException { synchronized(sync) { if ( Thread.currentThread() != sync.getOwner() ) { @@ -144,6 +145,7 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock { } } + @Override public final void lock() { synchronized(sync) { try { @@ -159,6 +161,7 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock { } } + @Override public final boolean tryLock(long timeout) throws InterruptedException { synchronized(sync) { final Thread cur = Thread.currentThread(); @@ -244,12 +247,14 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock { } + @Override public final void unlock() { synchronized(sync) { unlock(null); } } + @Override public final void unlock(Runnable taskAfterUnlockBeforeNotify) { synchronized(sync) { validateLocked(); @@ -293,12 +298,14 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock { } } + @Override public final int getQueueLength() { synchronized(sync) { return sync.queue.size(); } } + @Override public String toString() { return syncName()+"[count "+sync.holdCount+ ", qsz "+sync.queue.size()+", owner "+threadName(sync.getOwner())+"]"; |