diff options
Diffstat (limited to 'src/java/jogamp')
6 files changed, 64 insertions, 17 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())+"]"; diff --git a/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java b/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java index 326693a..5b5e42e 100644 --- a/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java +++ b/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java @@ -67,18 +67,23 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { /* package */ SingleThreadSync() { super(); } + @Override public final Thread getOwner() { return getExclusiveOwnerThread(); } + @Override public boolean isOwner(Thread t) { return getExclusiveOwnerThread()==t; } + @Override public final void setOwner(Thread t) { setExclusiveOwnerThread(t); } + @Override public final Throwable getLockedStack() { return lockedStack; } + @Override public final void setLockedStack(Throwable s) { List<Throwable> ls = LockDebugUtil.getRecursiveLockTrace(); if(s==null) { @@ -88,12 +93,18 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { } lockedStack = s; } + @Override public final int getHoldCount() { return holdCount; } + @Override public void incrHoldCount(Thread t) { holdCount++; } + @Override public void decrHoldCount(Thread t) { holdCount--; } + @Override public final int getQSz() { return qsz; } + @Override public final void incrQSz() { qsz++; } + @Override public final void decrQSz() { qsz--; } // lock count by same thread @@ -124,40 +135,43 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { } } + @Override public final Thread getOwner() { synchronized(sync) { return sync.getOwner(); } } - public final boolean isOwner() { - return isOwner(Thread.currentThread()); - } - + @Override public final boolean isOwner(Thread thread) { synchronized(sync) { - return sync.isOwner(thread) ; + return sync.isOwner(thread); } } + @Override public final boolean isLocked() { synchronized(sync) { return null != sync.getOwner(); } } + @Override public final boolean isLockedByOtherThread() { synchronized(sync) { - return null != sync.getOwner() && !sync.isOwner(Thread.currentThread()) ; + final Thread o = sync.getOwner(); + return null != o && Thread.currentThread() != o ; } } + @Override public final int getHoldCount() { synchronized(sync) { return sync.getHoldCount(); } } + @Override public final void validateLocked() throws RuntimeException { synchronized(sync) { if ( !sync.isOwner(Thread.currentThread()) ) { @@ -172,6 +186,7 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { } } + @Override public final void lock() { synchronized(sync) { try { @@ -187,6 +202,7 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { } } + @Override public final boolean tryLock(long timeout) throws InterruptedException { synchronized(sync) { final Thread cur = Thread.currentThread(); @@ -242,12 +258,14 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { } + @Override public final void unlock() { synchronized(sync) { unlock(null); } } + @Override public void unlock(Runnable taskAfterUnlockBeforeNotify) { synchronized(sync) { validateLocked(); @@ -277,12 +295,14 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { } } + @Override public final int getQueueLength() { synchronized(sync) { return sync.getQSz(); } } + @Override public String toString() { return syncName()+"[count "+sync.getHoldCount()+ ", qsz "+sync.getQSz()+", owner "+threadName(sync.getOwner())+"]"; diff --git a/src/java/jogamp/common/util/locks/RecursiveLockImplJava5.java b/src/java/jogamp/common/util/locks/RecursiveLockImplJava5.java index 7c88400..d9bc3df 100644 --- a/src/java/jogamp/common/util/locks/RecursiveLockImplJava5.java +++ b/src/java/jogamp/common/util/locks/RecursiveLockImplJava5.java @@ -14,6 +14,7 @@ public class RecursiveLockImplJava5 implements RecursiveLock { lock = new ReentrantLock(fair); } + @Override public void lock() { try { if(!tryLock(TIMEOUT)) { @@ -25,6 +26,7 @@ public class RecursiveLockImplJava5 implements RecursiveLock { owner = Thread.currentThread(); } + @Override public boolean tryLock(long timeout) throws InterruptedException { if(lock.tryLock(timeout, TimeUnit.MILLISECONDS)) { owner = Thread.currentThread(); @@ -33,10 +35,12 @@ public class RecursiveLockImplJava5 implements RecursiveLock { return false; } + @Override public void unlock() throws RuntimeException { unlock(null); } + @Override public void unlock(Runnable taskAfterUnlockBeforeNotify) { validateLocked(); owner = null; @@ -46,26 +50,27 @@ public class RecursiveLockImplJava5 implements RecursiveLock { lock.unlock(); } + @Override public boolean isLocked() { return lock.isLocked(); } + @Override public Thread getOwner() { return owner; } + @Override public boolean isLockedByOtherThread() { return lock.isLocked() && !lock.isHeldByCurrentThread(); } - public boolean isOwner() { - return lock.isHeldByCurrentThread(); - } - + @Override public boolean isOwner(Thread thread) { return lock.isLocked() && owner == thread; } + @Override public void validateLocked() throws RuntimeException { if ( !lock.isHeldByCurrentThread() ) { if ( !lock.isLocked() ) { @@ -76,10 +81,12 @@ public class RecursiveLockImplJava5 implements RecursiveLock { } } + @Override public int getHoldCount() { return lock.getHoldCount(); } + @Override public int getQueueLength() { return lock.getQueueLength(); } diff --git a/src/java/jogamp/common/util/locks/RecursiveThreadGroupLockImpl01Unfairish.java b/src/java/jogamp/common/util/locks/RecursiveThreadGroupLockImpl01Unfairish.java index 695c9c3..aac9348 100644 --- a/src/java/jogamp/common/util/locks/RecursiveThreadGroupLockImpl01Unfairish.java +++ b/src/java/jogamp/common/util/locks/RecursiveThreadGroupLockImpl01Unfairish.java @@ -43,12 +43,14 @@ public class RecursiveThreadGroupLockImpl01Unfairish threads = null; holdCountAdditionOwner = 0; } + @Override public final void incrHoldCount(Thread t) { super.incrHoldCount(t); if(!isOriginalOwner(t)) { holdCountAdditionOwner++; } } + @Override public final void decrHoldCount(Thread t) { super.decrHoldCount(t); if(!isOriginalOwner(t)) { @@ -62,6 +64,7 @@ public class RecursiveThreadGroupLockImpl01Unfairish public final boolean isOriginalOwner(Thread t) { return super.isOwner(t); } + @Override public final boolean isOwner(Thread t) { if(getExclusiveOwnerThread()==t) { return true; @@ -136,16 +139,19 @@ public class RecursiveThreadGroupLockImpl01Unfairish super(new ThreadGroupSync()); } + @Override public final boolean isOriginalOwner() { return isOriginalOwner(Thread.currentThread()); } + @Override public final boolean isOriginalOwner(Thread thread) { synchronized(sync) { return ((ThreadGroupSync)sync).isOriginalOwner(thread) ; } } + @Override public final void addOwner(Thread t) throws RuntimeException, IllegalArgumentException { validateLocked(); final Thread cur = Thread.currentThread(); @@ -159,6 +165,7 @@ public class RecursiveThreadGroupLockImpl01Unfairish tgSync.addOwner(t); } + @Override public final void unlock(Runnable taskAfterUnlockBeforeNotify) { synchronized(sync) { final Thread cur = Thread.currentThread(); @@ -196,11 +203,13 @@ public class RecursiveThreadGroupLockImpl01Unfairish } } + @Override public final void removeOwner(Thread t) throws RuntimeException, IllegalArgumentException { validateLocked(); ((ThreadGroupSync)sync).removeOwner(t); } + @Override public String toString() { final ThreadGroupSync tgSync = (ThreadGroupSync)sync; final int hc = sync.getHoldCount(); diff --git a/src/java/jogamp/common/util/locks/SingletonInstanceFileLock.java b/src/java/jogamp/common/util/locks/SingletonInstanceFileLock.java index f0bed66..f369941 100644 --- a/src/java/jogamp/common/util/locks/SingletonInstanceFileLock.java +++ b/src/java/jogamp/common/util/locks/SingletonInstanceFileLock.java @@ -71,11 +71,13 @@ public class SingletonInstanceFileLock extends SingletonInstance { setupFileCleanup(); } + @Override public final String getName() { return file.getPath(); } private void setupFileCleanup() { file.deleteOnExit(); Runtime.getRuntime().addShutdownHook(new Thread() { + @Override public void run() { unlock(); } diff --git a/src/java/jogamp/common/util/locks/SingletonInstanceServerSocket.java b/src/java/jogamp/common/util/locks/SingletonInstanceServerSocket.java index e5ba012..14a6aaf 100644 --- a/src/java/jogamp/common/util/locks/SingletonInstanceServerSocket.java +++ b/src/java/jogamp/common/util/locks/SingletonInstanceServerSocket.java @@ -81,6 +81,7 @@ public class SingletonInstanceServerSocket extends SingletonInstance { return singletonServer.getPortNumber(); } + @Override public final String getName() { return fullName; } @Override @@ -180,6 +181,7 @@ public class SingletonInstanceServerSocket extends SingletonInstance { return null; } + @Override public void run() { { final Thread currentThread = Thread.currentThread(); |