-
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 the possibility to do something else in case of a dependency fa…
…ilure during graph execution.
- Loading branch information
Showing
7 changed files
with
300 additions
and
9 deletions.
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
subprojects/jtrim-task-graph/src/main/java/org/jtrim2/taskgraph/DependencyErrorHandler.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,40 @@ | ||
package org.jtrim2.taskgraph; | ||
|
||
import org.jtrim2.cancel.CancellationToken; | ||
|
||
/** | ||
* Defines an error handler to be called instead of the associated node computation when | ||
* the node is not being executed due to a failed dependency. | ||
* | ||
* <h3>Thread safety</h3> | ||
* Instances must have the same thread-safety property as the computation of the associated | ||
* task node. | ||
* | ||
* <h4>Synchronization transparency</h4> | ||
* Instances are not expected to be synchronization transparent and are called in the | ||
* same context as the associated computation would have been. | ||
* | ||
* @see TaskNodeProperties#tryGetDependencyErrorHandler() | ||
*/ | ||
public interface DependencyErrorHandler { | ||
/** | ||
* Called when the associated node cannot be executed due to a dependency failure. This handler is | ||
* called on the same executor the associated node's computation would have been called on. | ||
* <P> | ||
* The graph execution is not considered completed before this method returns. | ||
* | ||
* @param cancelToken the cancellation token signaling the cancellation of the associated | ||
* task graph execution. This argument cannot be {@code null}. | ||
* @param nodeKey the {@code TaskNodeKey} identifying the node associated with the failure. | ||
* This argument cannot be {@code null}. | ||
* @param error the error causing the failure of the node execution. This argument cannot be | ||
* {@code null}. | ||
* | ||
* @throws Exception thrown in case of some serious failure. The thrown exception will be | ||
* suppressed by the error causing this method to be called. | ||
*/ | ||
public void handleDependencyError( | ||
CancellationToken cancelToken, | ||
TaskNodeKey<?, ?> nodeKey, | ||
Throwable error) throws Exception; | ||
} |
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
Oops, something went wrong.