Class LockManager
java.lang.Object
org.eclipse.rdf4j.common.concurrent.locks.LockManager
Manages a set of active locks. If any active lock is garbage collected it is automatically removed from the set and
logged.
- Author:
- James Leigh
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new set of locks.LockManager(boolean trackLocks)
Creates a new set of locks, optionally with lock tracking enabled.LockManager(boolean trackLocks, int collectionFrequency)
Creates a new set of locks, optionally with lock tracking enabled. -
Method Summary
Modifier and TypeMethodDescriptioncreateLock(String alias)
Creates a new active lock.boolean
If any locks in this collection that are still active.void
Blocks current thread until the number of active locks has reached zero.
-
Constructor Details
-
LockManager
public LockManager()Create a new set of locks. -
LockManager
public LockManager(boolean trackLocks)Creates a new set of locks, optionally with lock tracking enabled.- Parameters:
trackLocks
- Controls whether to keep a stack trace of active locks. Enabling lock tracking will add some overhead, but can be very useful for debugging.
-
LockManager
public LockManager(boolean trackLocks, int collectionFrequency)Creates a new set of locks, optionally with lock tracking enabled.- Parameters:
trackLocks
- Controls whether to keep a stack trace of active locks. Enabling lock tracking will add some overhead, but can be very useful for debugging.collectionFrequency
- Number of milliseconds to block the first thread, waiting for active locks to finish, before running the memory garbage collection, to free abandoned active locks.
-
-
Method Details
-
isActiveLock
public boolean isActiveLock()If any locks in this collection that are still active.- Returns:
true
of one or more locks that have not be released.
-
waitForActiveLocks
Blocks current thread until the number of active locks has reached zero.- Throws:
InterruptedException
- if any thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
-
createLock
Creates a new active lock. This increases the number of active locks until itsLock.release()
method is called, which decreases the number of active locks by the same amount.- Parameters:
alias
- a short string used to log abandon locks- Returns:
- an active lock
-