Skip to content

Commit 25cbb8f

Browse files
committed
More JavaDoc-s
1 parent ee3d026 commit 25cbb8f

File tree

3 files changed

+55
-7
lines changed

3 files changed

+55
-7
lines changed

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

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ public boolean cancel(boolean mayInterruptIfRunning) {
108108

109109
/**
110110
* <p>Returns a promise that is resolved successfully when all {@link CompletionStage}-s passed as parameters are completed normally;
111-
* if any promise completed exceptionally, then resulting promise is resolved exceptionally as well.
111+
* if any promise completed exceptionally, then resulting promise is resolved faulty as well.
112112
* <p>The resolved result of this promise contains a list of the resolved results of the {@link CompletionStage}-s passed as an
113113
* argument at corresponding positions.
114-
*
114+
* <p>When resulting promise is resolved faulty, any remaining {@link CompletionStage}-s is cancelled.
115115
* @param promises
116116
* an array of {@link CompletionStage}-s to combine
117117
* @return
@@ -124,11 +124,12 @@ public static <T> Promise<List<T>> all(final CompletionStage<? extends T>... pro
124124

125125
/**
126126
* <p>Returns a promise that is resolved successfully when any {@link CompletionStage} passed as parameters is completed normally (race is possible);
127-
* if all promises completed exceptionally, then resulting promise is resolved exceptionally as well.
127+
* if all promises completed exceptionally, then resulting promise is resolved faulty as well.
128128
* <p>The resolved result of this promise contains a value of the first resolved result of the {@link CompletionStage}-s passed as an
129129
* argument.
130+
* <p>When resulting promise is resolved successfully, any remaining {@link CompletionStage}-s is cancelled.
130131
* @param promises
131-
* an array of {@link CompletionStage}-s to combine
132+
* an array of {@link CompletionStage}-s to combine
132133
* @return
133134
* a combined promise
134135
*/
@@ -139,13 +140,13 @@ public static <T> Promise<T> any(final CompletionStage<? extends T>... promises)
139140

140141
/**
141142
* <p>Returns a promise that is resolved successfully when any {@link CompletionStage} passed as parameters is completed normally (race is possible);
142-
* if any promise completed exceptionally before first result is available, then resulting promise is resolved exceptionally as well
143+
* if any promise completed exceptionally before first result is available, then resulting promise is resolved faulty as well
143144
* (unlike non-Strict variant, where exceptions are ignored if result is available at all).
144145
* <p>The resolved result of this promise contains a value of the first resolved result of the {@link CompletionStage}-s passed as an
145146
* argument.
146-
*
147+
* <p>When resulting promise is resolved either successfully or faulty, any remaining {@link CompletionStage}-s is cancelled.
147148
* @param promises
148-
* an array of {@link CompletionStage}-s to combine
149+
* an array of {@link CompletionStage}-s to combine
149150
* @return
150151
* a combined promise
151152
*/
@@ -154,11 +155,44 @@ public static <T> Promise<T> anyStrict(final CompletionStage<? extends T>... pro
154155
return unwrap(atLeast(1, 0, true, promises), true);
155156
}
156157

158+
/**
159+
* <p>Generalization of the {@link Promises#any(CompletionStage...)} method.</p>
160+
* <p>Returns a promise that is resolved successfully when at least <code>minResultCount</code> of {@link CompletionStage}-s passed as parameters
161+
* are completed normally (race is possible); if less than <code>minResultCount</code> of promises completed normally, then resulting promise
162+
* is resolved faulty.
163+
* <p>The resolved result of this promise contains a list of the resolved results of the {@link CompletionStage}-s passed as an
164+
* 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.
166+
*
167+
* @param minResultsCount
168+
* a minimum number of promises that should be completed normally to resolve resulting promise successfully
169+
* @param promises
170+
* an array of {@link CompletionStage}-s to combine
171+
* @return
172+
* a combined promise
173+
*/
157174
@SafeVarargs
158175
public static <T> Promise<List<T>> atLeast(final int minResultsCount, final CompletionStage<? extends T>... promises) {
159176
return atLeast(minResultsCount, promises.length - minResultsCount, true, promises);
160177
}
161178

179+
/**
180+
* <p>Generalization of the {@link Promises#anyStrict(CompletionStage...)} method.</p>
181+
* <p>Returns a promise that is resolved successfully when at least <code>minResultCount</code> of {@link CompletionStage}-s passed as parameters
182+
* are completed normally (race is possible); if less than <code>minResultCount</code> of promises completed normally, then resulting promise
183+
* is resolved faulty. If any promise completed exceptionally <em>before</em> <code>minResultCount</code> of results are available, then
184+
* resulting promise is resolved faulty as well.
185+
* <p>The resolved result of this promise contains a list of the resolved results of the {@link CompletionStage}-s passed as an
186+
* 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+
*
189+
* @param minResultsCount
190+
* a minimum number of promises that should be completed normally to resolve resulting promise successfully
191+
* @param promises
192+
* an array of {@link CompletionStage}-s to combine
193+
* @return
194+
* a combined promise
195+
*/
162196
@SafeVarargs
163197
public static <T> Promise<List<T>> atLeastStrict(final int minResultsCount, final CompletionStage<? extends T>... promises) {
164198
return atLeast(minResultsCount, 0, true, promises);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
import java.util.concurrent.Callable;
1919
import java.util.concurrent.ExecutorService;
2020

21+
/**
22+
* Specialization of {@link ExecutorService} that uses {@link Promise} as a result of <code>submit(...)</code> methods.
23+
*
24+
* @author vsilaev
25+
*
26+
*/
2127
public interface TaskExecutorService extends ExecutorService {
2228

2329
<T> Promise<T> submit(Callable<T> task);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
import java.util.concurrent.ThreadPoolExecutor;
2424
import java.util.concurrent.TimeUnit;
2525

26+
27+
/**
28+
* <p>Concrete implementation of {@link TaskExecutorService} interface.
29+
* <p>Specialization of {@link ThreadPoolExecutor} that uses {@link Promise} as a result of <code>submit(...)</code> methods.
30+
*
31+
* @author vsilaev
32+
*
33+
*/
2634
public class ThreadPoolTaskExecutor extends ThreadPoolExecutor implements TaskExecutorService {
2735

2836
public ThreadPoolTaskExecutor(int corePoolSize, int maximumPoolSize,

0 commit comments

Comments
 (0)