Class ThreadLock
java.lang.Object
de.aristaflow.adept2.util.locking.ReentrantLock<Thread>
de.aristaflow.adept2.util.locking.ThreadLock
This class provides a reentrant read/write-lock based on threads. When using
the
It is merely for convenience purpose and allow type safety (Java does not allow
ObjectEqualityLockCount together with this class, one has the
same behaviour as ReentrantReadWriteLock. It is merely for convenience purpose and allow type safety (Java does not allow
ReentrantLock<Thread>.class).-
Nested Class Summary
Nested classes/interfaces inherited from class de.aristaflow.adept2.util.locking.ReentrantLock
ReentrantLock.Lock, ReentrantLock.ReadLock, ReentrantLock.WriteLock -
Field Summary
Fields inherited from class de.aristaflow.adept2.util.locking.ReentrantLock
logger, notification, readLock, writeLock -
Constructor Summary
ConstructorsConstructorDescriptionThreadLock(boolean exclusive, Logger logger) Creates a newThreadLockresemblingReentrantReadWriteLockin non-exclusive mode, that is, it is based on threads, it usesObject.equals(Object)and is either exclusive or it supports (non-exclusive) readers and (exclusive) writers.ThreadLock(Class<? extends LockCountManager<Thread>> lockCountManager, boolean exclusive, LockNotification<Thread> notification, Logger logger) Creates a newThreadLockusing the designated lock count manager and the designated exclusive mode.ThreadLock(Class<? extends LockCountManager<Thread>> lockCountManager, boolean exclusive, Logger logger) Creates a newThreadLockusing the designated lock count manager and the designated exclusive mode.ThreadLock(Logger logger) Creates a newThreadLockresemblingReentrantLock, that is, it is based on threads, it usesObject.equals(Object)and it is exclusive. -
Method Summary
Methods inherited from class de.aristaflow.adept2.util.locking.ReentrantLock
invalidate, isReadLocked, isWriteLocked, readLock, writeLock
-
Constructor Details
-
ThreadLock
public ThreadLock(Logger logger) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException Creates a newThreadLockresemblingReentrantLock, that is, it is based on threads, it usesObject.equals(Object)and it is exclusive.- Parameters:
logger- The logger for log messages.- Throws:
NoSuchMethodException- Should never happen. If the object equality lock count manager has no constructor without parameters, aNouSuchMethodExceptionwill be thrown.InstantiationException- Should never happen. If the object equality lock count manager cannot be instantiated or does not have a parameterless constructor, anInstantiationExceptionwill be thrown.IllegalAccessException- Should never happen. If the object equality lock count manager class or its constructor is not accessible, anIllegalAccessExceptionwill be thrown.InvocationTargetException- If the constructor of the object equality lock count manager throws an exception, this will be wrapped by anInvocationTargetException.
-
ThreadLock
public ThreadLock(boolean exclusive, Logger logger) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException Creates a newThreadLockresemblingReentrantReadWriteLockin non-exclusive mode, that is, it is based on threads, it usesObject.equals(Object)and is either exclusive or it supports (non-exclusive) readers and (exclusive) writers.- Parameters:
exclusive- Whether to create an exclusive lock or a read/write-lock.logger- The logger for log messages.- Throws:
NoSuchMethodException- Should never happen. If the object equality lock count manager has no constructor without parameters, aNouSuchMethodExceptionwill be thrown.InstantiationException- Should never happen. If the object equality lock count manager cannot be instantiated or does not have a parameterless constructor, anInstantiationExceptionwill be thrown.IllegalAccessException- Should never happen. If the object equality lock count manager class or its constructor is not accessible, anIllegalAccessExceptionwill be thrown.InvocationTargetException- If the constructor of the object equality lock count manager throws an exception, this will be wrapped by anInvocationTargetException.
-
ThreadLock
public ThreadLock(Class<? extends LockCountManager<Thread>> lockCountManager, boolean exclusive, Logger logger) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException Creates a newThreadLockusing the designated lock count manager and the designated exclusive mode. This constructor is for usage byObjectLockManager.- Parameters:
lockCountManager- The manager counting locks for threads. The provided class needs an accessible (public) constructor without parameters.exclusive- Whether to create an exclusive lock or a read/write-lock.logger- The logger for log messages.- Throws:
NoSuchMethodException- Should never happen. If the object equality lock count manager has no constructor without parameters, aNouSuchMethodExceptionwill be thrown.InstantiationException- If the designated lock count manager class cannot be instantiated or does not have a parameterless constructor, anInstantiationExceptionwill be thrown.IllegalAccessException- If the designated lock count manager class or its constructor is not accessible, anIllegalAccessExceptionwill be thrown.InvocationTargetException- If the constructor of the object equality lock count manager throws an exception, this will be wrapped by anInvocationTargetException.
-
ThreadLock
public ThreadLock(Class<? extends LockCountManager<Thread>> lockCountManager, boolean exclusive, LockNotification<Thread> notification, Logger logger) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException Creates a newThreadLockusing the designated lock count manager and the designated exclusive mode. The designated notification will be used for notifying a successful lock or unlock while locking and unlocking, that is, the notification will be atomically with respect to locking/unlocking. This constructor is for usage byObjectLockManager.- Parameters:
lockCountManager- The manager counting locks for threads. The provided class needs an accessible (public) constructor without parameters.exclusive- Whether to create an exclusive lock or a read/write-lock.notification- The notification to call directly but atomically after locking and unlocking. If this isnull, no notification will be sent.logger- The logger for log messages.- Throws:
NoSuchMethodException- Should never happen. If the object equality lock count manager has no constructor without parameters, aNouSuchMethodExceptionwill be thrown.InstantiationException- If the designated lock count manager class cannot be instantiated or does not have a parameterless constructor, anInstantiationExceptionwill be thrown.IllegalAccessException- If the designated lock count manager class or its constructor is not accessible, anIllegalAccessExceptionwill be thrown.InvocationTargetException- If the constructor of the object equality lock count manager throws an exception, this will be wrapped by anInvocationTargetException.
-