de.grogra.util
public class LockableImpl extends java.lang.Object implements Lockable
Lockable.DeadLockException| Constructor and Description |
|---|
LockableImpl() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
enterWriteLock() |
void |
execute(LockProtectedRunnable task,
boolean write)
Asynchronously executes a
task such that it possesses
a lock on this Lockable. |
void |
execute(LockProtectedRunnable task,
Lock retained)
Asynchronously executes a
task using a lock which
has been retained before within another task. |
void |
executeForcedly(LockProtectedRunnable task,
boolean write)
Synchronously executes a
task such that it possesses
a lock on this Lockable. |
void |
executeForcedly(LockProtectedRunnable task,
Lock retained)
Synchronously executes a
task using a lock which
has been retained before within another task. |
protected void |
executeInAllowedThread(java.lang.Runnable r) |
long |
getMaxWaitingTime()
Returns the waiting time of the pending task which is waiting longest,
or
-1 if there is no pending task. |
int |
getQueueLength()
Returns the current number of tasks which are waiting for
locked execution.
|
protected void |
invokeRun(LockProtectedRunnable task,
boolean sync,
Lock lock) |
protected boolean |
isAllowedThread(boolean write) |
boolean |
isLocked(boolean write)
Determines if the current thread has a lock for this
Lockable. |
protected void |
leaveWriteLock() |
protected void enterWriteLock()
public void execute(LockProtectedRunnable task, boolean write)
Lockabletask such that it possesses
a lock on this Lockable. Note that the execution
is asynchronous, so that the thread in which
the task will actually be executed may differ from the current thread.public void execute(LockProtectedRunnable task, Lock retained)
Lockabletask using a lock which
has been retained before within another task.
Note that the execution
is asynchronous, so that the thread in which
the task will actually be executed may differ from the current thread.execute in interface Lockabletask - the task to executeretained - the previously retained lockLock.retain()public void executeForcedly(LockProtectedRunnable task, boolean write) throws java.lang.InterruptedException, Lockable.DeadLockException
Lockabletask such that it possesses
a lock on this Lockable. The execution
is performed in the current thread.executeForcedly in interface Lockabletask - the task to executewrite - shall a write lock be obtained?java.lang.InterruptedExceptionLockable.DeadLockExceptionpublic void executeForcedly(LockProtectedRunnable task, Lock retained) throws java.lang.InterruptedException
Lockabletask using a lock which
has been retained before within another task. The execution
is performed in the current thread.executeForcedly in interface Lockabletask - the task to executeretained - the previously retained lockjava.lang.InterruptedExceptionLock.retain()protected void executeInAllowedThread(java.lang.Runnable r)
public long getMaxWaitingTime()
Lockable-1 if there is no pending task.getMaxWaitingTime in interface Lockablepublic int getQueueLength()
LockablegetQueueLength in interface Lockableprotected void invokeRun(LockProtectedRunnable task, boolean sync, Lock lock)
protected boolean isAllowedThread(boolean write)
public boolean isLocked(boolean write)
LockableLockable.protected void leaveWriteLock()