public final class Resource extends Object
Queue.Executable
uses while running.
This is used in Queue
to support basic mutual exclusion/locks. If two
Queue.Task
s require the same Resource
, they will not
be run at the same time.
Resources are compared by using their names
, and
need not have the "same object" semantics.
Modifier and Type | Field and Description |
---|---|
String |
displayName
Human-readable name of this resource.
|
int |
numConcurrentWrite
Maximum number of concurrent write.
|
Resource |
parent
Parent resource.
|
Constructor and Description |
---|
Resource(Resource parent,
String displayName) |
Resource(Resource parent,
String displayName,
int numConcurrentWrite) |
Resource(String displayName) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
isCollidingWith(Resource that,
int count)
Checks the resource collision.
|
String |
toString() |
@NonNull public final String displayName
@CheckForNull public final Resource parent
A child resource is considered a part of the parent resource, so acquiring the parent resource always imply acquiring all the child resources.
public final int numConcurrentWrite
public Resource(@CheckForNull Resource parent, @NonNull String displayName, int numConcurrentWrite)
public Resource(@NonNull String displayName)
public boolean isCollidingWith(Resource that, int count)
count
- If we are testing W/W conflict, total # of write counts.
For R/W conflict test, this value should be set to Integer.MAX_VALUE
.Copyright © 2004–2021. All rights reserved.