|
16 | 16 |
|
17 | 17 | package com.linkedin.parseq;
|
18 | 18 |
|
19 |
| -import com.linkedin.parseq.internal.TaskLogger; |
| 19 | +import com.linkedin.parseq.internal.TaskListener; |
20 | 20 | import com.linkedin.parseq.promise.Promise;
|
21 |
| -import com.linkedin.parseq.trace.Related; |
22 | 21 | import com.linkedin.parseq.trace.ShallowTrace;
|
23 | 22 | import com.linkedin.parseq.trace.Trace;
|
24 | 23 |
|
25 |
| -import java.util.Collection; |
26 |
| -import java.util.Set; |
27 |
| - |
28 | 24 | /**
|
29 | 25 | * A task represents a deferred execution that also contains its resulting
|
30 | 26 | * value. In addition, tasks include some tracing information that can be
|
|
38 | 34 | public interface Task<T> extends Promise<T>, Cancellable
|
39 | 35 | {
|
40 | 36 | /**
|
41 |
| - * Returns the name of this task. |
42 |
| - * |
43 |
| - * @return the name of this task |
| 37 | + * Returns the name of this task. If no name was set during construction |
| 38 | + * this method will return the value of {@link #toString()}. In most |
| 39 | + * cases it is preferable to explicitly set a name. |
44 | 40 | */
|
45 |
| - public String getName(); |
| 41 | + String getName(); |
46 | 42 |
|
47 | 43 | /**
|
48 | 44 | * Returns the priority for this task.
|
@@ -71,41 +67,38 @@ public interface Task<T> extends Promise<T>, Cancellable
|
71 | 67 | boolean setPriority(int priority);
|
72 | 68 |
|
73 | 69 | /**
|
74 |
| - * Attempts to run the task with the given context. This method is |
75 |
| - * reserved for use by {@link Engine} and {@link Context}. |
76 |
| - * |
77 |
| - * @param context the context to use while running this step |
78 |
| - * @param taskLogger the logger used for task events |
79 |
| - * @param parent the parent of this task |
80 |
| - * @param predecessors that lead to the execution of this task |
81 |
| - */ |
82 |
| - void contextRun(Context context, TaskLogger taskLogger, |
83 |
| - Task<?> parent, Collection<Task<?>> predecessors); |
84 |
| - |
85 |
| - |
86 |
| - /** |
87 |
| - * Returns the ShallowTrace for this task. The ShallowTrace will be |
88 |
| - * a point-in-time snapshot and may change over time until the task is |
89 |
| - * completed. |
90 |
| - * |
91 |
| - * @return the ShallowTrace related to this task |
| 70 | + * Returns a trace for this task alone. The trace is a point-in-time |
| 71 | + * snapshot, so successive invocations of {@code getShallowTrace} may |
| 72 | + * return different results. |
92 | 73 | */
|
93 | 74 | ShallowTrace getShallowTrace();
|
94 | 75 |
|
95 | 76 | /**
|
96 |
| - * Returns the Trace for this task. The Trace will be a point-in-time snapshot |
| 77 | + * Returns the trace for this task. The trace will be a point-in-time snapshot |
97 | 78 | * and may change over time until the task is completed.
|
98 | 79 | *
|
99 |
| - * @return the Trace related to this task |
| 80 | + * @return the trace related to this task |
100 | 81 | */
|
101 | 82 | Trace getTrace();
|
102 | 83 |
|
103 | 84 | /**
|
104 |
| - * Returns the set of relationships of this task. The parent relationships are not included. |
| 85 | + * Attempts to bind this task to the given context. A task may only be bound |
| 86 | + * once. This method is reserved for use by the ParSeq framework only. |
105 | 87 | *
|
106 |
| - * @see com.linkedin.parseq.trace.Relationship the available relationships |
107 |
| - * @return the set of relationships of this task. |
| 88 | + * @param context the context to assign to this task. |
| 89 | + * @return {@code true} if the assignment was successful. |
| 90 | + */ |
| 91 | + boolean assignContext(Context context); |
| 92 | + |
| 93 | + /** |
| 94 | + * Attempts to run the task with the given context. This method is for use by |
| 95 | + * the ParSeq framework only. |
108 | 96 | */
|
109 |
| - Set<Related<Task<?>>> getRelationships(); |
| 97 | + void contextRun(); |
110 | 98 |
|
| 99 | + /** |
| 100 | + * Adds a listener to this task that is notified each time the task changes |
| 101 | + * state. This method is for use by the ParSeq framework only. |
| 102 | + */ |
| 103 | + void addTaskListener(TaskListener tracingTaskListener); |
111 | 104 | }
|
0 commit comments