Skip to content

Commit bb32795

Browse files
committed
Fxing JavaDoc-s
1 parent 25cbb8f commit bb32795

File tree

8 files changed

+64
-8
lines changed

8 files changed

+64
-8
lines changed

src/main/java/net/tascalate/concurrent/AbstractCompletableTask.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
* @author vsilaev
4646
*
4747
* @param <T>
48+
* a type of the successfully executed task result
4849
*/
4950
abstract class AbstractCompletableTask<T> extends PromiseAdapter<T> implements Promise<T> {
5051

src/main/java/net/tascalate/concurrent/AbstractDelegatingPromise.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
* @author vsilaev
3131
*
3232
* @param <T>
33+
* a type of the successfully resolved promise value
3334
* @param <D>
35+
* a type of the concrete {@link CompletionStage} subclass
3436
*/
3537
abstract public class AbstractDelegatingPromise<T, D extends CompletionStage<T>> implements Promise<T> {
3638
final protected D completionStage;

src/main/java/net/tascalate/concurrent/CompletablePromise.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
* @author vsilaev
3131
*
3232
* @param <T>
33+
* a type of the successfully resolved promise value
3334
*/
3435
public class CompletablePromise<T> extends AbstractDelegatingPromise<T, CompletableFuture<T>> implements Promise<T> {
3536

src/main/java/net/tascalate/concurrent/CompletableTask.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* @author vsilaev
2727
*
2828
* @param <T>
29+
* a type of the successfully executed task result
2930
*/
3031
public class CompletableTask<T> extends AbstractCompletableTask<T> implements RunnableFuture<T> {
3132

@@ -63,9 +64,11 @@ public void run() {
6364
* </pre>
6465
* All of <code>myMapper</code>, <code>myTransformer</code>, <code>myConsumer</code>, <code>myActtion</code> will be executed using <code>myExecutor</code>
6566
*
67+
* @param <T>
68+
* a type of the successfully executed task result
6669
* @param value
67-
* a resolved value of the promise
68-
* @param executor
70+
* a task result
71+
* @param defaultExecutor
6972
* a default {@link Executor} to run functions passed to async composition methods
7073
* (like <code>thenApplyAsync</code> / <code>thenAcceptAsync</code> / <code>whenCompleteAsync</code> etc.)
7174
* @return

src/main/java/net/tascalate/concurrent/Promise.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
* @author vsilaev
3232
*
3333
* @param <T>
34+
* a type of the successfully resolved promise value
3435
*/
3536
public interface Promise<T> extends Future<T>, CompletionStage<T> {
3637

src/main/java/net/tascalate/concurrent/PromiseAdapter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
* @author vsilaev
3636
*
3737
* @param <T>
38+
* a type of the successfully resolved promise value
3839
*/
3940
abstract public class PromiseAdapter<T> implements Promise<T> {
4041
protected static final Executor SAME_THREAD_EXECUTOR = new Executor() {

src/main/java/net/tascalate/concurrent/Promises.java

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public class Promises {
3535

3636
/**
3737
* Method to create a successfully resolved {@link Promise} with a value provided
38+
* @param <T>
39+
* a type of the value
3840
* @param value
3941
* a value to wrap
4042
* @return
@@ -61,6 +63,8 @@ public static Promise<?> failure(Throwable exception) {
6163

6264
/**
6365
* Adapts a stage passed to the {@link Promise} API
66+
* @param <T>
67+
* a type of the value
6468
* @param stage
6569
* a {@link CompletionStage} to be wrapped
6670
* @return
@@ -111,7 +115,9 @@ public boolean cancel(boolean mayInterruptIfRunning) {
111115
* if any promise completed exceptionally, then resulting promise is resolved faulty as well.
112116
* <p>The resolved result of this promise contains a list of the resolved results of the {@link CompletionStage}-s passed as an
113117
* argument at corresponding positions.
114-
* <p>When resulting promise is resolved faulty, any remaining {@link CompletionStage}-s is cancelled.
118+
* <p>When resulting promise is resolved faulty, all remaining incomplete {@link CompletionStage}-s are cancelled.
119+
* @param <T>
120+
* a common supertype of the resulting values
115121
* @param promises
116122
* an array of {@link CompletionStage}-s to combine
117123
* @return
@@ -127,7 +133,10 @@ public static <T> Promise<List<T>> all(final CompletionStage<? extends T>... pro
127133
* if all promises completed exceptionally, then resulting promise is resolved faulty as well.
128134
* <p>The resolved result of this promise contains a value of the first resolved result of the {@link CompletionStage}-s passed as an
129135
* argument.
130-
* <p>When resulting promise is resolved successfully, any remaining {@link CompletionStage}-s is cancelled.
136+
* <p>When resulting promise is resolved successfully, all remaining incomplete {@link CompletionStage}-s are cancelled.
137+
*
138+
* @param <T>
139+
* a common supertype of the resulting values
131140
* @param promises
132141
* an array of {@link CompletionStage}-s to combine
133142
* @return
@@ -144,7 +153,9 @@ public static <T> Promise<T> any(final CompletionStage<? extends T>... promises)
144153
* (unlike non-Strict variant, where exceptions are ignored if result is available at all).
145154
* <p>The resolved result of this promise contains a value of the first resolved result of the {@link CompletionStage}-s passed as an
146155
* argument.
147-
* <p>When resulting promise is resolved either successfully or faulty, any remaining {@link CompletionStage}-s is cancelled.
156+
* <p>When resulting promise is resolved either successfully or faulty, all remaining incomplete {@link CompletionStage}-s are cancelled.
157+
* @param <T>
158+
* a common supertype of the resulting values
148159
* @param promises
149160
* an array of {@link CompletionStage}-s to combine
150161
* @return
@@ -162,8 +173,10 @@ public static <T> Promise<T> anyStrict(final CompletionStage<? extends T>... pro
162173
* is resolved faulty.
163174
* <p>The resolved result of this promise contains a list of the resolved results of the {@link CompletionStage}-s passed as an
164175
* argument at corresponding positions. Non-completed or completed exceptionally promises have <code>null</code> values.
165-
* <p>When resulting promise is resolved successfully, any remaining {@link CompletionStage}-s is cancelled.
176+
* <p>When resulting promise is resolved successfully, all remaining incomplete {@link CompletionStage}-s are cancelled.
166177
*
178+
* @param <T>
179+
* a common supertype of the resulting values
167180
* @param minResultsCount
168181
* a minimum number of promises that should be completed normally to resolve resulting promise successfully
169182
* @param promises
@@ -184,8 +197,10 @@ public static <T> Promise<List<T>> atLeast(final int minResultsCount, final Comp
184197
* resulting promise is resolved faulty as well.
185198
* <p>The resolved result of this promise contains a list of the resolved results of the {@link CompletionStage}-s passed as an
186199
* argument at corresponding positions. Non-completed promises have <code>null</code> values.
187-
* <p>When resulting promise is resolved either successfully or faulty, any remaining {@link CompletionStage}-s is cancelled.
188-
*
200+
* <p>When resulting promise is resolved either successfully or faulty, all remaining incomplete {@link CompletionStage}-s are cancelled.
201+
*
202+
* @param <T>
203+
* a common supertype of the resulting values
189204
* @param minResultsCount
190205
* a minimum number of promises that should be completed normally to resolve resulting promise successfully
191206
* @param promises
@@ -198,6 +213,32 @@ public static <T> Promise<List<T>> atLeastStrict(final int minResultsCount, fina
198213
return atLeast(minResultsCount, 0, true, promises);
199214
}
200215

216+
/**
217+
* <p>General method to combine several {@link CompletionStage}-s passed as arguments into single promise.</p>
218+
* <p>The resulting promise is resolved successfully when at least <code>minResultCount</code> of {@link CompletionStage}-s passed as parameters
219+
* are completed normally (race is possible).
220+
* <p>If less than <code>minResultCount</code> of promises completed normally, then resulting promise is resolved faulty.
221+
* <p>If <code>maxErrorsCount</code> of promises completed exceptionally <em>before</em> <code>minResultCount</code> of results are available, then
222+
* resulting promise is resolved faulty as well.
223+
* <p>The resolved result of this promise contains a list of the resolved results of the {@link CompletionStage}-s passed as an
224+
* argument at corresponding positions. Non-completed promises and promises completed exceptionally have <code>null</code> values.
225+
* <p>When resulting promise is resolved either successfully or faulty, all remaining incomplete {@link CompletionStage}-s are cancelled <em>if</em>
226+
* <code>cancelRemaining</code> parameter is <code>true</code>.
227+
*
228+
* @param <T>
229+
* a common supertype of the resulting values
230+
* @param minResultsCount
231+
* a minimum number of promises that should be completed normally to resolve resulting promise successfully
232+
* @param maxErrorsCount
233+
* a maximum number of promises that may be completed exceptionally before resolving resulting promise faulty
234+
* @param cancelRemaining
235+
* a flag that indicates (if true) whether or not all remaining incomplete {@link CompletionStage}-s should be cancelled
236+
* once a resulting promise outcome is known.
237+
* @param promises
238+
* an array of {@link CompletionStage}-s to combine
239+
* @return
240+
* a combined promise
241+
*/
201242
@SafeVarargs
202243
public static <T> Promise<List<T>> atLeast(final int minResultsCount, final int maxErrorsCount, final boolean cancelRemaining,
203244
final CompletionStage<? extends T>... promises) {

src/main/java/net/tascalate/concurrent/TaskExecutors.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
import java.util.concurrent.TimeUnit;
3131
import java.util.concurrent.TimeoutException;
3232

33+
/**
34+
* The drop-in replacement for {@link Executors} utility class that returns various useful implementations
35+
* of {@link TaskExecutorService} instead of standard {@link ExecutorService}.
36+
* @author vsilaev
37+
*
38+
*/
3339
public class TaskExecutors {
3440
/**
3541
* Creates a thread pool that reuses a fixed number of threads operating off

0 commit comments

Comments
 (0)