Skip to content

Commit e8e5414

Browse files
committed
Add cross-reference @see tags between related wait/sleep methods
Link Workflow.sleep, Workflow.newTimer, Workflow.await, and Async.await in Javadoc to help developers discover blocking vs non-blocking alternatives.
1 parent 0b9d817 commit e8e5414

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

temporal-sdk/src/main/java/io/temporal/workflow/Async.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ public static <R> Promise<R> retry(
240240
* contain code that mutates workflow state.
241241
* @return Promise that completes when the condition becomes true, or completes exceptionally with
242242
* CanceledFailure if the enclosing CancellationScope is canceled.
243+
* @see Workflow#await(java.util.function.Supplier) for a blocking version
243244
*/
244245
public static Promise<Void> await(java.util.function.Supplier<Boolean> unblockCondition) {
245246
return WorkflowInternal.awaitAsync(unblockCondition);
@@ -258,6 +259,8 @@ public static Promise<Void> await(java.util.function.Supplier<Boolean> unblockCo
258259
* <li>false if the timeout expired before the condition was satisfied
259260
* <li>exceptionally with CanceledFailure if the enclosing CancellationScope is canceled
260261
* </ul>
262+
*
263+
* @see Workflow#await(Duration, java.util.function.Supplier) for a blocking version
261264
*/
262265
public static Promise<Boolean> await(
263266
Duration timeout, java.util.function.Supplier<Boolean> unblockCondition) {

temporal-sdk/src/main/java/io/temporal/workflow/Workflow.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ public static CancellationScope newDetachedCancellationScope(Runnable runnable)
474474
*
475475
* @return feature that becomes ready when at least specified number of seconds passes. promise is
476476
* failed with {@link CanceledFailure} if enclosing scope is canceled.
477+
* @see #sleep(Duration) for a blocking version
477478
*/
478479
public static Promise<Void> newTimer(Duration delay) {
479480
return WorkflowInternal.newTimer(delay);
@@ -485,6 +486,7 @@ public static Promise<Void> newTimer(Duration delay) {
485486
*
486487
* @return feature that becomes ready when at least specified number of seconds passes. promise is
487488
* failed with {@link CanceledFailure} if enclosing scope is canceled.
489+
* @see #sleep(Duration) for a blocking version
488490
*/
489491
public static Promise<Void> newTimer(Duration delay, TimerOptions options) {
490492
return WorkflowInternal.newTimer(delay, options);
@@ -566,12 +568,20 @@ public static long currentTimeMillis() {
566568
return WorkflowInternal.currentTimeMillis();
567569
}
568570

569-
/** Must be called instead of {@link Thread#sleep(long)} to guarantee determinism. */
571+
/**
572+
* Must be called instead of {@link Thread#sleep(long)} to guarantee determinism.
573+
*
574+
* @see #newTimer(Duration) for a non-blocking version that returns a Promise
575+
*/
570576
public static void sleep(Duration duration) {
571577
WorkflowInternal.sleep(duration);
572578
}
573579

574-
/** Must be called instead of {@link Thread#sleep(long)} to guarantee determinism. */
580+
/**
581+
* Must be called instead of {@link Thread#sleep(long)} to guarantee determinism.
582+
*
583+
* @see #newTimer(Duration) for a non-blocking version that returns a Promise
584+
*/
575585
public static void sleep(long millis) {
576586
WorkflowInternal.sleep(Duration.ofMillis(millis));
577587
}
@@ -585,6 +595,7 @@ public static void sleep(long millis) {
585595
* contain any time based conditions. Use {@link #await(Duration, Supplier)} for those
586596
* instead.
587597
* @throws CanceledFailure if thread (or current {@link CancellationScope} was canceled).
598+
* @see Async#await(java.util.function.Supplier) for a non-blocking version that returns a Promise
588599
*/
589600
public static void await(Supplier<Boolean> unblockCondition) {
590601
WorkflowInternal.await(
@@ -606,6 +617,8 @@ public static void await(Supplier<Boolean> unblockCondition) {
606617
* Use timeout parameter for those.
607618
* @return false if timed out.
608619
* @throws CanceledFailure if thread (or current {@link CancellationScope} was canceled).
620+
* @see Async#await(Duration, java.util.function.Supplier) for a non-blocking version that returns
621+
* a Promise
609622
*/
610623
public static boolean await(Duration timeout, Supplier<Boolean> unblockCondition) {
611624
return WorkflowInternal.await(

0 commit comments

Comments
 (0)