Interface ResourceLock
-
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Implementing Classes:
CompositeLock,NopLock,SingleLock
@API(status=STABLE, since="1.10") public interface ResourceLock extends java.lang.AutoCloseableA lock for a one or more resources.- Since:
- 1.3
- See Also:
HierarchicalTestExecutorService.TestTask.getResourceLock()
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ResourceLockacquire()Acquire this resource lock, potentially blocking.default voidclose()java.util.List<ExclusiveResource>getResources(){@return the exclusive resources this lock represents}default booleanisCompatible(ResourceLock other){@return whether the given lock is compatible with this lock}booleanisExclusive(){@return whether this lock requires exclusiveness}voidrelease()Release this resource lock.
-
-
-
Method Detail
-
acquire
ResourceLock acquire() throws java.lang.InterruptedException
Acquire this resource lock, potentially blocking.- 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
-
release
void release()
Release this resource lock.
-
close
default void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
getResources
java.util.List<ExclusiveResource> getResources()
{@return the exclusive resources this lock represents}
-
isExclusive
boolean isExclusive()
{@return whether this lock requires exclusiveness}
-
isCompatible
default boolean isCompatible(ResourceLock other)
{@return whether the given lock is compatible with this lock}- Parameters:
other- the other lock to check for compatibility
-
-