Class CompositeLock
- java.lang.Object
-
- org.junit.platform.engine.support.hierarchical.CompositeLock
-
- All Implemented Interfaces:
java.lang.AutoCloseable,ResourceLock
class CompositeLock extends java.lang.Object implements ResourceLock
- Since:
- 1.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classCompositeLock.CompositeLockManagedBlocker
-
Field Summary
Fields Modifier and Type Field Description private booleanexclusiveprivate java.util.List<java.util.concurrent.locks.Lock>locksprivate java.util.List<ExclusiveResource>resources
-
Constructor Summary
Constructors Constructor Description CompositeLock(java.util.List<ExclusiveResource> resources, java.util.List<java.util.concurrent.locks.Lock> locks)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourceLockacquire()Acquire this resource lock, potentially blocking.private voidacquireAllLocks()(package private) java.util.List<java.util.concurrent.locks.Lock>getLocks()java.util.List<ExclusiveResource>getResources(){@return the exclusive resources this lock represents}booleanisExclusive(){@return whether this lock requires exclusiveness}voidrelease()Release this resource lock.private voidrelease(java.util.List<java.util.concurrent.locks.Lock> acquiredLocks)java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.junit.platform.engine.support.hierarchical.ResourceLock
close, isCompatible
-
-
-
-
Field Detail
-
resources
private final java.util.List<ExclusiveResource> resources
-
locks
private final java.util.List<java.util.concurrent.locks.Lock> locks
-
exclusive
private final boolean exclusive
-
-
Constructor Detail
-
CompositeLock
CompositeLock(java.util.List<ExclusiveResource> resources, java.util.List<java.util.concurrent.locks.Lock> locks)
-
-
Method Detail
-
getResources
public java.util.List<ExclusiveResource> getResources()
Description copied from interface:ResourceLock{@return the exclusive resources this lock represents}- Specified by:
getResourcesin interfaceResourceLock
-
getLocks
java.util.List<java.util.concurrent.locks.Lock> getLocks()
-
acquire
public ResourceLock acquire() throws java.lang.InterruptedException
Description copied from interface:ResourceLockAcquire this resource lock, potentially blocking.- Specified by:
acquirein interfaceResourceLock- Returns:
- this lock so it can easily be used in a try-with-resources statement.
- Throws:
java.lang.InterruptedException- if the calling thread is interrupted while waiting to acquire this lock
-
acquireAllLocks
private void acquireAllLocks() throws java.lang.InterruptedException- Throws:
java.lang.InterruptedException
-
release
public void release()
Description copied from interface:ResourceLockRelease this resource lock.- Specified by:
releasein interfaceResourceLock
-
release
private void release(java.util.List<java.util.concurrent.locks.Lock> acquiredLocks)
-
isExclusive
public boolean isExclusive()
Description copied from interface:ResourceLock{@return whether this lock requires exclusiveness}- Specified by:
isExclusivein interfaceResourceLock
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-