Class ExclusiveResource
- java.lang.Object
-
- org.junit.platform.engine.support.hierarchical.ExclusiveResource
-
@API(status=STABLE, since="1.10") public class ExclusiveResource extends java.lang.ObjectAn exclusive resource identified by a key with a lock mode that is used to synchronize access to shared resources when executing nodes in parallel.- Since:
- 1.3
- See Also:
Node.getExecutionMode()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExclusiveResource.LockModeLockModetranslates to the respectiveReadWriteLocklocks.
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.util.Comparator<ExclusiveResource>COMPARATORstatic java.lang.StringGLOBAL_KEYKey of the global resource lock that all direct children of the engine descriptor acquire in read mode by default: "org.junit.platform.engine.support.hierarchical.ExclusiveResource.GLOBAL_KEY"(package private) static ExclusiveResourceGLOBAL_READ(package private) static ExclusiveResourceGLOBAL_READ_WRITEprivate inthashprivate java.lang.Stringkeyprivate ExclusiveResource.LockModelockMode
-
Constructor Summary
Constructors Constructor Description ExclusiveResource(java.lang.String key, ExclusiveResource.LockMode lockMode)Create a newExclusiveResource.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.lang.StringgetKey()Get the key of this resource.ExclusiveResource.LockModegetLockMode()Get the lock mode of this resource.private static java.util.Comparator<java.lang.String>globalKeyFirst()inthashCode()java.lang.StringtoString()
-
-
-
Field Detail
-
GLOBAL_KEY
@API(status=STABLE, since="1.10") public static final java.lang.String GLOBAL_KEYKey of the global resource lock that all direct children of the engine descriptor acquire in read mode by default: "org.junit.platform.engine.support.hierarchical.ExclusiveResource.GLOBAL_KEY"If any node requires an exclusive resource with the same key in read-write mode, the lock will be coarsened to be acquired by the node's ancestor that is a direct child of the engine descriptor and all of the ancestor's descendants will be forced to run in the same thread.
- Since:
- 1.7
- See Also:
- Constant Field Values
-
GLOBAL_READ
static final ExclusiveResource GLOBAL_READ
-
GLOBAL_READ_WRITE
static final ExclusiveResource GLOBAL_READ_WRITE
-
COMPARATOR
static final java.util.Comparator<ExclusiveResource> COMPARATOR
-
key
private final java.lang.String key
-
lockMode
private final ExclusiveResource.LockMode lockMode
-
hash
private int hash
-
-
Constructor Detail
-
ExclusiveResource
public ExclusiveResource(java.lang.String key, ExclusiveResource.LockMode lockMode)Create a newExclusiveResource.- Parameters:
key- the identifier of the resource; nevernullor blanklockMode- the lock mode to use to synchronize access to the resource; nevernull
-
-
Method Detail
-
globalKeyFirst
private static java.util.Comparator<java.lang.String> globalKeyFirst()
-
getKey
public java.lang.String getKey()
Get the key of this resource.
-
getLockMode
public ExclusiveResource.LockMode getLockMode()
Get the lock mode of this resource.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-