java.lang.Object
de.grogra.util.LockableImpl
- All Implemented Interfaces:
Lockable
- Direct Known Subclasses:
PersistenceManager
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.grogra.util.Lockable
Lockable.DeadLockException -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidexecute(LockProtectedRunnable task, boolean write) Asynchronously executes atasksuch that it possesses a lock on thisLockable.voidexecute(LockProtectedRunnable task, Lock retained) Asynchronously executes ataskusing a lock which has been retained before within another task.voidexecuteForcedly(LockProtectedRunnable task, boolean write) Synchronously executes atasksuch that it possesses a lock on thisLockable.voidexecuteForcedly(LockProtectedRunnable task, Lock retained) Synchronously executes ataskusing a lock which has been retained before within another task.protected voidlongReturns the waiting time of the pending task which is waiting longest, or-1if there is no pending task.intReturns the current number of tasks which are waiting for locked execution.protected voidinvokeRun(LockProtectedRunnable task, boolean sync, Lock lock) protected booleanisAllowedThread(boolean write) booleanisLocked(boolean write) Determines if the current thread has a lock for thisLockable.voidprotected voidde.grogra.util.LockableImpl.LockImpllock(boolean hadLock, boolean forWrite)
-
Constructor Details
-
LockableImpl
public LockableImpl()
-
-
Method Details
-
killLock
-
lock
public de.grogra.util.LockableImpl.LockImpl lock(boolean hadLock, boolean forWrite) -
execute
Description copied from interface:LockableAsynchronously executes atasksuch that it possesses a lock on thisLockable. 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
Description copied from interface:LockableAsynchronously executes ataskusing 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. -
executeForcedly
public void executeForcedly(LockProtectedRunnable task, boolean write) throws InterruptedException, Lockable.DeadLockException Description copied from interface:LockableSynchronously executes atasksuch that it possesses a lock on thisLockable. The execution is performed in the current thread.- Specified by:
executeForcedlyin interfaceLockable- Parameters:
task- the task to executewrite- shall a write lock be obtained?- Throws:
InterruptedExceptionLockable.DeadLockException
-
executeForcedly
Description copied from interface:LockableSynchronously executes ataskusing a lock which has been retained before within another task. The execution is performed in the current thread.- Specified by:
executeForcedlyin interfaceLockable- Parameters:
task- the task to executeretained- the previously retained lock- Throws:
InterruptedException- See Also:
-
isLocked
public boolean isLocked(boolean write) Description copied from interface:LockableDetermines if the current thread has a lock for thisLockable. -
getQueueLength
public int getQueueLength()Description copied from interface:LockableReturns the current number of tasks which are waiting for locked execution.- Specified by:
getQueueLengthin interfaceLockable- Returns:
- current number of waiting tasks
-
getMaxWaitingTime
public long getMaxWaitingTime()Description copied from interface:LockableReturns the waiting time of the pending task which is waiting longest, or-1if there is no pending task.- Specified by:
getMaxWaitingTimein interfaceLockable- Returns:
- current maximum waiting time of pending tasks
-
isAllowedThread
protected boolean isAllowedThread(boolean write) -
executeInAllowedThread
-
invokeRun
-
enterWriteLock
protected void enterWriteLock() -
leaveWriteLock
protected void leaveWriteLock()
-