-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a methods for TaskGraphExecutor to be able to track individual …
…nodes.
- Loading branch information
Showing
5 changed files
with
244 additions
and
4 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
subprojects/jtrim-task-graph/src/main/java/org/jtrim2/taskgraph/BuiltGraph.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.jtrim2.taskgraph; | ||
|
||
import java.util.HashSet; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
import org.jtrim2.taskgraph.basic.DependencyDag; | ||
|
||
import static java.util.Collections.*; | ||
import static org.jtrim2.utils.ExceptionHelper.*; | ||
|
||
/** | ||
* Defines a whole task execution graph. That is, the set of nodes and the | ||
* edges. | ||
* | ||
* <h3>Thread safety</h3> | ||
* Instances of {@code BuiltGraph} are immutable and so can be used safely by | ||
* multiple threads concurrently. | ||
* | ||
* <h4>Synchronization transparency</h4> | ||
* The methods of {@code BuiltGraph} are <I>synchronization transparent</I>. | ||
*/ | ||
public final class BuiltGraph { | ||
private final Set<TaskNodeKey<?, ?>> nodes; | ||
private final DependencyDag<TaskNodeKey<?, ?>> graph; | ||
|
||
/** | ||
* Creates a new task execution graph with the given edges and nodes. | ||
* | ||
* @param nodes specifies the set of all the nodes of the task execution | ||
* graph. This argument cannot be {@code null} and cannot contain | ||
* {@code null} elements. | ||
* @param graph defines the edges of the task execution graph. That is, | ||
* the dependencies between the nodes. This argument cannot be {@code null}. | ||
*/ | ||
public BuiltGraph( | ||
Set<TaskNodeKey<?, ?>> nodes, | ||
DependencyDag<TaskNodeKey<?, ?>> graph) { | ||
this.nodes = unmodifiableSet(checkNotNullElements(new HashSet<>(nodes), "nodes")); | ||
this.graph = Objects.requireNonNull(graph, "graph"); | ||
} | ||
|
||
/** | ||
* Returns the nodes of the task execution graph. | ||
* | ||
* @return the nodes of the task execution graph. The returned set is never | ||
* {@code null} and is not modifiable. | ||
*/ | ||
public Set<TaskNodeKey<?, ?>> getNodes() { | ||
return nodes; | ||
} | ||
|
||
/** | ||
* Returns the edges of the task execution graph. That is, the dependencies | ||
* between the nodes. | ||
* | ||
* @return the edges of the task execution graph. This method never returns | ||
* {@code null}. | ||
*/ | ||
public DependencyDag<TaskNodeKey<?, ?>> getGraph() { | ||
return graph; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters