summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/util
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-06-27 04:18:53 +0200
committerSven Gothel <[email protected]>2012-06-27 04:18:53 +0200
commit834b9e530e652b7ff7c5e222720bce3ad2b11c5f (patch)
treebac459da1a84abec07f70f74204a4e1deca1d226 /src/java/com/jogamp/common/util
parent9a71703904ebfec343fb2c7266343d37a2e4c3db (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/com/jogamp/common/util')
-rw-r--r--src/java/com/jogamp/common/util/locks/Lock.java1
-rw-r--r--src/java/com/jogamp/common/util/locks/RecursiveLock.java2
-rw-r--r--src/java/com/jogamp/common/util/locks/RecursiveThreadGroupLock.java2
-rw-r--r--src/java/com/jogamp/common/util/locks/SingletonInstance.java5
-rw-r--r--src/java/com/jogamp/common/util/locks/ThreadLock.java (renamed from src/java/com/jogamp/common/util/locks/LockExt.java)14
5 files changed, 16 insertions, 8 deletions
diff --git a/src/java/com/jogamp/common/util/locks/Lock.java b/src/java/com/jogamp/common/util/locks/Lock.java
index cf3fd01..33a093b 100644
--- a/src/java/com/jogamp/common/util/locks/Lock.java
+++ b/src/java/com/jogamp/common/util/locks/Lock.java
@@ -77,5 +77,6 @@ public interface Lock {
*/
void unlock() throws RuntimeException;
+ /** Query if locked */
boolean isLocked();
}
diff --git a/src/java/com/jogamp/common/util/locks/RecursiveLock.java b/src/java/com/jogamp/common/util/locks/RecursiveLock.java
index efa9789..9eb9c8c 100644
--- a/src/java/com/jogamp/common/util/locks/RecursiveLock.java
+++ b/src/java/com/jogamp/common/util/locks/RecursiveLock.java
@@ -31,7 +31,7 @@ package com.jogamp.common.util.locks;
/**
* Reentrance capable locking toolkit.
*/
-public interface RecursiveLock extends LockExt {
+public interface RecursiveLock extends ThreadLock {
/** Return the number of locks issued to this lock by the same thread.
* A hold count of 0 identifies this lock as unlocked.<br>
* A hold count of 1 identifies this lock as locked.<br>
diff --git a/src/java/com/jogamp/common/util/locks/RecursiveThreadGroupLock.java b/src/java/com/jogamp/common/util/locks/RecursiveThreadGroupLock.java
index 5e11f29..626199f 100644
--- a/src/java/com/jogamp/common/util/locks/RecursiveThreadGroupLock.java
+++ b/src/java/com/jogamp/common/util/locks/RecursiveThreadGroupLock.java
@@ -123,6 +123,7 @@ public interface RecursiveThreadGroupLock extends RecursiveLock {
*
* {@inheritDoc}
*/
+ @Override
void unlock() throws RuntimeException;
/**
@@ -132,6 +133,7 @@ public interface RecursiveThreadGroupLock extends RecursiveLock {
*
* {@inheritDoc}
*/
+ @Override
void unlock(Runnable taskAfterUnlockBeforeNotify);
}
diff --git a/src/java/com/jogamp/common/util/locks/SingletonInstance.java b/src/java/com/jogamp/common/util/locks/SingletonInstance.java
index c085371..5f2718b 100644
--- a/src/java/com/jogamp/common/util/locks/SingletonInstance.java
+++ b/src/java/com/jogamp/common/util/locks/SingletonInstance.java
@@ -68,8 +68,10 @@ public abstract class SingletonInstance implements Lock {
public final long getPollPeriod() { return poll_ms; }
public abstract String getName();
+ @Override
public final String toString() { return getName(); }
+ @Override
public synchronized void lock() throws RuntimeException {
try {
do {
@@ -82,6 +84,7 @@ public abstract class SingletonInstance implements Lock {
}
}
+ @Override
public synchronized boolean tryLock(long maxwait) throws RuntimeException {
if(locked) {
return true;
@@ -110,6 +113,7 @@ public abstract class SingletonInstance implements Lock {
}
protected abstract boolean tryLockImpl();
+ @Override
public void unlock() throws RuntimeException {
if(locked) {
locked = !unlockImpl();
@@ -121,6 +125,7 @@ public abstract class SingletonInstance implements Lock {
}
protected abstract boolean unlockImpl();
+ @Override
public synchronized boolean isLocked() {
return locked;
}
diff --git a/src/java/com/jogamp/common/util/locks/LockExt.java b/src/java/com/jogamp/common/util/locks/ThreadLock.java
index 974c11a..65260bc 100644
--- a/src/java/com/jogamp/common/util/locks/LockExt.java
+++ b/src/java/com/jogamp/common/util/locks/ThreadLock.java
@@ -31,19 +31,19 @@ package com.jogamp.common.util.locks;
/**
* Extending the {@link Lock} features with convenient functionality.
*/
-public interface LockExt extends Lock {
+public interface ThreadLock extends Lock {
+ /** Query whether the lock is hold by the a thread other than the current thread. */
+ boolean isLockedByOtherThread();
+
+ /** Query whether the lock is hold by the given thread. */
+ boolean isOwner(Thread thread);
+
/**
* @return the Thread owning this lock if locked, otherwise null
*/
Thread getOwner();
- boolean isLockedByOtherThread();
-
- boolean isOwner();
-
- boolean isOwner(Thread thread);
-
/**
* @throws RuntimeException if current thread does not hold the lock
*/