@@ -36,6 +36,18 @@ public interface WaitableFuture {
36
36
*/
37
37
Object getId ();
38
38
39
+ /**
40
+ * Wait {@link Long#MAX_VALUE} msec. for the asynchronous operation to complete. The attached listeners will be
41
+ * notified when the operation is completed.
42
+ *
43
+ * @return {@code true} if the operation is completed.
44
+ * @throws IOException if failed - specifically {@link java.io.InterruptedIOException} if waiting was interrupted
45
+ * @see #await(long, CancelOption[])
46
+ */
47
+ default boolean await () throws IOException {
48
+ return await (new CancelOption [0 ]);
49
+ }
50
+
39
51
/**
40
52
* Wait {@link Long#MAX_VALUE} msec. for the asynchronous operation to complete. The attached listeners will be
41
53
* notified when the operation is completed.
@@ -50,6 +62,19 @@ default boolean await(CancelOption... options) throws IOException {
50
62
return await (Long .MAX_VALUE , options );
51
63
}
52
64
65
+ /**
66
+ * Wait for the asynchronous operation to complete with the specified timeout.
67
+ *
68
+ * @param timeout The number of time units to wait
69
+ * @param unit The {@link TimeUnit} for waiting
70
+ * @return {@code true} if the operation is completed.
71
+ * @throws IOException if failed - specifically {@link java.io.InterruptedIOException} if waiting was interrupted
72
+ * @see #await(long, CancelOption[])
73
+ */
74
+ default boolean await (long timeout , TimeUnit unit ) throws IOException {
75
+ return await (timeout , unit , new CancelOption [0 ]);
76
+ }
77
+
53
78
/**
54
79
* Wait for the asynchronous operation to complete with the specified timeout.
55
80
*
@@ -65,6 +90,18 @@ default boolean await(long timeout, TimeUnit unit, CancelOption... options) thro
65
90
return await (unit .toMillis (timeout ), options );
66
91
}
67
92
93
+ /**
94
+ * Wait for the asynchronous operation to complete with the specified timeout.
95
+ *
96
+ * @param timeout The maximum duration to wait, <code>null</code> to wait forever
97
+ * @return {@code true} if the operation is completed.
98
+ * @throws IOException if failed - specifically {@link java.io.InterruptedIOException} if waiting was interrupted
99
+ * @see #await(long, CancelOption[])
100
+ */
101
+ default boolean await (Duration timeout ) throws IOException {
102
+ return await (timeout , new CancelOption [0 ]);
103
+ }
104
+
68
105
/**
69
106
* Wait for the asynchronous operation to complete with the specified timeout.
70
107
*
@@ -79,6 +116,17 @@ default boolean await(Duration timeout, CancelOption... options) throws IOExcept
79
116
return timeout != null ? await (timeout .toMillis (), options ) : await (options );
80
117
}
81
118
119
+ /**
120
+ * Wait for the asynchronous operation to complete with the specified timeout.
121
+ *
122
+ * @param timeoutMillis Wait time in milliseconds
123
+ * @return {@code true} if the operation is completed.
124
+ * @throws IOException if failed - specifically {@link java.io.InterruptedIOException} if waiting was interrupted
125
+ */
126
+ default boolean await (long timeoutMillis ) throws IOException {
127
+ return await (timeoutMillis , new CancelOption [0 ]);
128
+ }
129
+
82
130
/**
83
131
* Wait for the asynchronous operation to complete with the specified timeout.
84
132
*
@@ -90,6 +138,17 @@ default boolean await(Duration timeout, CancelOption... options) throws IOExcept
90
138
*/
91
139
boolean await (long timeoutMillis , CancelOption ... options ) throws IOException ;
92
140
141
+ /**
142
+ * Wait {@link Long#MAX_VALUE} msec. for the asynchronous operation to complete uninterruptibly. The attached
143
+ * listeners will be notified when the operation is completed.
144
+ *
145
+ * @return {@code true} if the operation is completed.
146
+ * @see #awaitUninterruptibly(long, CancelOption[])
147
+ */
148
+ default boolean awaitUninterruptibly () {
149
+ return awaitUninterruptibly (new CancelOption [0 ]);
150
+ }
151
+
93
152
/**
94
153
* Wait {@link Long#MAX_VALUE} msec. for the asynchronous operation to complete uninterruptibly. The attached
95
154
* listeners will be notified when the operation is completed.
@@ -103,6 +162,18 @@ default boolean awaitUninterruptibly(CancelOption... options) {
103
162
return awaitUninterruptibly (Long .MAX_VALUE , options );
104
163
}
105
164
165
+ /**
166
+ * Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
167
+ *
168
+ * @param timeout The number of time units to wait
169
+ * @param unit The {@link TimeUnit} for waiting
170
+ * @return {@code true} if the operation is completed.
171
+ * @see #awaitUninterruptibly(long, CancelOption[])
172
+ */
173
+ default boolean awaitUninterruptibly (long timeout , TimeUnit unit ) {
174
+ return awaitUninterruptibly (timeout , unit , new CancelOption [0 ]);
175
+ }
176
+
106
177
/**
107
178
* Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
108
179
*
@@ -117,6 +188,16 @@ default boolean awaitUninterruptibly(long timeout, TimeUnit unit, CancelOption..
117
188
return awaitUninterruptibly (unit .toMillis (timeout ), options );
118
189
}
119
190
191
+ /**
192
+ * Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
193
+ *
194
+ * @param timeoutMillis Wait time, <code>null</code> to wait forever
195
+ * @return {@code true} if the operation is finished.
196
+ */
197
+ default boolean awaitUninterruptibly (Duration timeoutMillis ) {
198
+ return awaitUninterruptibly (timeoutMillis , new CancelOption [0 ]);
199
+ }
200
+
120
201
/**
121
202
* Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
122
203
*
@@ -129,6 +210,16 @@ default boolean awaitUninterruptibly(Duration timeoutMillis, CancelOption... opt
129
210
return timeoutMillis != null ? awaitUninterruptibly (timeoutMillis .toMillis (), options ) : awaitUninterruptibly (options );
130
211
}
131
212
213
+ /**
214
+ * Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
215
+ *
216
+ * @param timeoutMillis Wait time in milliseconds
217
+ * @return {@code true} if the operation is finished.
218
+ */
219
+ default boolean awaitUninterruptibly (long timeoutMillis ) {
220
+ return awaitUninterruptibly (timeoutMillis , new CancelOption [0 ]);
221
+ }
222
+
132
223
/**
133
224
* Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
134
225
*
0 commit comments