author | mgronlun |
Wed, 18 Sep 2019 14:57:57 +0200 | |
branch | JEP-349-branch |
changeset 58209 | 7993ced88081 |
parent 58201 | 2654d1b665bf |
child 58212 | 412d8e77f931 |
permissions | -rw-r--r-- |
57361 | 1 |
/* |
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package jdk.jfr.consumer; |
|
27 |
||
28 |
import java.io.IOException; |
|
29 |
import java.nio.file.Path; |
|
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
30 |
import java.security.AccessControlContext; |
57434 | 31 |
import java.security.AccessController; |
57361 | 32 |
import java.time.Duration; |
57372
50ca040843ea
Prepare infrastructure for multiple implementations of EventStream
egahlin
parents:
57361
diff
changeset
|
33 |
import java.time.Instant; |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
34 |
import java.util.Objects; |
57361 | 35 |
import java.util.function.Consumer; |
36 |
||
57717
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
37 |
import jdk.jfr.internal.SecuritySupport; |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
38 |
import jdk.jfr.internal.Utils; |
58145
bc54ed8d908a
Move implementation into jdk.jfr.internal.consumer
egahlin
parents:
58129
diff
changeset
|
39 |
import jdk.jfr.internal.consumer.EventDirectoryStream; |
bc54ed8d908a
Move implementation into jdk.jfr.internal.consumer
egahlin
parents:
58129
diff
changeset
|
40 |
import jdk.jfr.internal.consumer.EventFileStream; |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
41 |
import jdk.jfr.internal.consumer.FileAccess; |
57627 | 42 |
|
57361 | 43 |
/** |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
44 |
* Represents a stream of events. |
58129 | 45 |
* <p> |
46 |
* A stream is a sequence of events and the way to interact with a stream is to |
|
58200 | 47 |
* register actions. The {@code EventStream} interface is not to be implemented |
48 |
* and future versions of the JDK may prevent this completely. |
|
58129 | 49 |
* <p> |
50 |
* To receive a notification when an event arrives, register an action using the |
|
51 |
* {@link #onEvent(Consumer)} method. To filter the stream for an event with a |
|
52 |
* specific name, use {@link #onEvent(String, Consumer)} method. |
|
58200 | 53 |
* <p> |
58129 | 54 |
* By default, the same {@code RecordedEvent} object can be used for |
55 |
* representing two or more distinct events. The object can be delivered |
|
56 |
* multiple times to the same action as well as to other actions. If the life |
|
58201 | 57 |
* span of the event object exceeds that of the action, the |
58129 | 58 |
* {@link #setReuse(boolean)} method should be set to {@code false} so that a |
59 |
* new object is allocated for each event. |
|
60 |
* <p> |
|
61 |
* Events are delivered in batches. To receive a notification when a batch is |
|
62 |
* complete, register an action using the {@link #onFlush(Runnable)} method. |
|
63 |
* This is an opportunity to aggregate or push data to external systems while |
|
64 |
* the Java Virtual Machine (JVM) is preparing the next batch. |
|
65 |
* <p> |
|
58209 | 66 |
* Events within a batch are sorted chronologically by their end time. |
67 |
* Well-ordering of events is only maintained for events available to the JVM at |
|
68 |
* the point of flush, i.e. for the set of events delivered as a unit in a |
|
69 |
* single batch. Events delivered in a batch could therefore be out-of-order |
|
70 |
* compared to events delivered in a previous batch, but never out-of-order with |
|
71 |
* events within the same batch. If ordering is not a concern, sorting can be |
|
72 |
* disabled using the {@link #setOrdered(boolean)} method. |
|
58129 | 73 |
* <p> |
74 |
* To dispatch events to registered actions, the stream must be started. To |
|
75 |
* start processing in the current thread, invoke the {@link #start()} method. |
|
76 |
* To process actions asynchronously in a separate thread, invoke the |
|
77 |
* {@link #startAsync()} method. To await completion of the stream, use the |
|
78 |
* awaitTermination {@link #awaitTermination()} or the {link |
|
79 |
* {@link #awaitTermination(Duration)} method. |
|
80 |
* <p> |
|
81 |
* When a stream ends it is automatically closed. To manually stop processing of |
|
58200 | 82 |
* events, close the stream by invoking the {@link #close()} method. A stream |
58201 | 83 |
* can also be automatically closed in exceptional circumstances, for example if |
84 |
* the JVM that is being monitored exits. To receive a notification in any of |
|
58200 | 85 |
* these occasions, use the {@link #onClose(Runnable)} method to register an |
86 |
* action. |
|
58129 | 87 |
* <p> |
88 |
* If an unexpected exception occurs in an action, it is possible to catch the |
|
89 |
* exception in an error handler. An error handler can be registered using the |
|
90 |
* {@link #onError(Runnable)} method. If no error handler is registered, the |
|
91 |
* default behavior is to print the exception and its backtrace to the standard |
|
92 |
* error stream. |
|
93 |
* <p> |
|
58200 | 94 |
* The following example shows how an {@code EventStream} can be used to listen |
95 |
* to events on a JVM running Flight Recorder |
|
96 |
* |
|
58152 | 97 |
* <pre> |
98 |
* <code> |
|
99 |
* try (EventStream es = EventStream.openRepository()) { |
|
100 |
* es.onEvent("jdk.CPULoad", event -> { |
|
101 |
* System.out.println("CPU Load " + event.getEndTime()); |
|
102 |
* System.out.println(" Machine total: " + 100 * event.getFloat("machineTotal") + "%"); |
|
103 |
* System.out.println(" JVM User: " + 100 * event.getFloat("jvmUser") + "%"); |
|
104 |
* System.out.println(" JVM System: " + 100 * event.getFloat("jvmSystem") + "%"); |
|
105 |
* System.out.println(); |
|
106 |
* System.gc(); |
|
107 |
* }); |
|
108 |
* es.onEvent("jdk.GarbageCollection", event -> { |
|
109 |
* System.out.println("Garbage collection: " + event.getLong("gcId")); |
|
110 |
* System.out.println(" Cause: " + event.getString("cause")); |
|
111 |
* System.out.println(" Total pause: " + event.getDuration("sumOfPauses")); |
|
112 |
* System.out.println(" Longest pause: " + event.getDuration("longestPause")); |
|
113 |
* System.out.println(); |
|
114 |
* }); |
|
115 |
* es.start(); |
|
116 |
* } |
|
117 |
* </code> |
|
118 |
* </pre> |
|
58129 | 119 |
* <p> |
58152 | 120 |
* To start recording together with the stream, see {@link RecordingStream}. |
58129 | 121 |
* |
58200 | 122 |
* @since 14 |
57361 | 123 |
*/ |
124 |
public interface EventStream extends AutoCloseable { |
|
125 |
/** |
|
58129 | 126 |
* Creates a stream from the repository of the current Java Virtual Machine |
127 |
* (JVM). |
|
57627 | 128 |
* <p> |
129 |
* By default, the stream starts with the next event flushed by Flight |
|
130 |
* Recorder. |
|
131 |
* |
|
132 |
* @return an event stream, not {@code null} |
|
133 |
* |
|
134 |
* @throws IOException if a stream can't be opened, or an I/O error occurs |
|
135 |
* when trying to access the repository |
|
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
136 |
* |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
137 |
* @throws SecurityException if a security manager exists and the caller |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
138 |
* does not have |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
139 |
* {@code FlightRecorderPermission("accessFlightRecorder")} |
57627 | 140 |
*/ |
141 |
public static EventStream openRepository() throws IOException { |
|
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
142 |
Utils.checkAccessFlightRecorder(); |
57717
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
143 |
return new EventDirectoryStream(AccessController.getContext(), null, SecuritySupport.PRIVILIGED, false); |
57627 | 144 |
} |
145 |
||
146 |
/** |
|
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
147 |
* Creates an event stream from a disk repository. |
57449 | 148 |
* <p> |
57627 | 149 |
* By default, the stream starts with the next event flushed by Flight |
150 |
* Recorder. |
|
57361 | 151 |
* |
152 |
* @param directory location of the disk repository, not {@code null} |
|
57449 | 153 |
* |
57361 | 154 |
* @return an event stream, not {@code null} |
57449 | 155 |
* |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
156 |
* @throws IOException if a stream can't be opened, or an I/O error occurs |
57627 | 157 |
* when trying to access the repository |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
158 |
* |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
159 |
* @throws SecurityException if a security manager exists and its |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
160 |
* {@code checkRead} method denies read access to the directory, or |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
161 |
* files in the directory. |
57361 | 162 |
*/ |
163 |
public static EventStream openRepository(Path directory) throws IOException { |
|
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
164 |
Objects.nonNull(directory); |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
165 |
AccessControlContext acc = AccessController.getContext(); |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
166 |
return new EventDirectoryStream(acc, directory, FileAccess.UNPRIVILIGED, false); |
57361 | 167 |
} |
168 |
||
169 |
/** |
|
57449 | 170 |
* Creates an event stream from a file. |
171 |
* <p> |
|
57452
6fabe73e5d9a
Reduced allocation pressure. Fix getValue for startTime and duration
egahlin
parents:
57449
diff
changeset
|
172 |
* By default, the stream starts with the first event in the file. |
57361 | 173 |
* |
174 |
* @param file location of the file, not {@code null} |
|
57449 | 175 |
* |
57361 | 176 |
* @return an event stream, not {@code null} |
57372
50ca040843ea
Prepare infrastructure for multiple implementations of EventStream
egahlin
parents:
57361
diff
changeset
|
177 |
* |
58129 | 178 |
* @throws IOException if the file can't be opened, or an I/O error occurs |
57376 | 179 |
* during reading |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
180 |
* |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
181 |
* @throws SecurityException if a security manager exists and its |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
182 |
* {@code checkRead} method denies read access to the file |
57361 | 183 |
*/ |
58197 | 184 |
static EventStream openFile(Path file) throws IOException { |
57985 | 185 |
return new EventFileStream(AccessController.getContext(), file); |
57372
50ca040843ea
Prepare infrastructure for multiple implementations of EventStream
egahlin
parents:
57361
diff
changeset
|
186 |
} |
50ca040843ea
Prepare infrastructure for multiple implementations of EventStream
egahlin
parents:
57361
diff
changeset
|
187 |
|
50ca040843ea
Prepare infrastructure for multiple implementations of EventStream
egahlin
parents:
57361
diff
changeset
|
188 |
/** |
58129 | 189 |
* Registers an action to perform on all events in the stream. |
57361 | 190 |
* |
58129 | 191 |
* @param action an action to perform on each {@code RecordedEvent}, not |
192 |
* {@code null} |
|
57361 | 193 |
*/ |
194 |
void onEvent(Consumer<RecordedEvent> action); |
|
195 |
||
196 |
/** |
|
58129 | 197 |
* Registers an action to perform on all events matching a name. |
57361 | 198 |
* |
199 |
* @param eventName the name of the event, not {@code null} |
|
57449 | 200 |
* |
58129 | 201 |
* @param action an action to perform on each {@code RecordedEvent} matching |
202 |
* the event name, not {@code null} |
|
57361 | 203 |
*/ |
204 |
void onEvent(String eventName, Consumer<RecordedEvent> action); |
|
205 |
||
206 |
/** |
|
58129 | 207 |
* Registers an action to perform after the stream has been flushed. |
57361 | 208 |
* |
58129 | 209 |
* @param action an action to perform after the stream has been |
210 |
* flushed, not {@code null} |
|
57361 | 211 |
*/ |
212 |
void onFlush(Runnable action); |
|
213 |
||
214 |
/** |
|
58129 | 215 |
* Registers an action to perform if an exception occurs. |
57971 | 216 |
* <p> |
58129 | 217 |
* if an action is not registered, an exception stack trace is printed to |
218 |
* standard error. |
|
57971 | 219 |
* <p> |
58129 | 220 |
* Registering an action overrides the default behavior. If multiple actions |
221 |
* have been registered, they are performed in the order of registration. |
|
222 |
* <p> |
|
223 |
* If this method itself throws an exception, resulting behavior is |
|
224 |
* undefined. |
|
57971 | 225 |
* |
58129 | 226 |
* @param action an action to perform if an exception occurs, not |
57971 | 227 |
* {@code null} |
228 |
*/ |
|
229 |
void onError(Consumer<Throwable> action); |
|
230 |
||
231 |
/** |
|
58129 | 232 |
* Registers an action to perform when the stream is closed. |
57449 | 233 |
* <p> |
58129 | 234 |
* If the stream is already closed, the action will be performed immediately |
57449 | 235 |
* in the current thread. |
57361 | 236 |
* |
58129 | 237 |
* @param action an action to perform after the stream is closed, not |
238 |
* {@code null} |
|
239 |
* @see #close() |
|
57361 | 240 |
*/ |
241 |
void onClose(Runnable action); |
|
242 |
||
243 |
/** |
|
58129 | 244 |
* Releases all resources associated with this stream. |
57361 | 245 |
*/ |
246 |
void close(); |
|
247 |
||
248 |
/** |
|
58129 | 249 |
* Unregisters an action. |
57361 | 250 |
* <p> |
58129 | 251 |
* If the action has been registered multiple times, all instances are |
252 |
* unregistered. |
|
57361 | 253 |
* |
58129 | 254 |
* @param action the action to unregister, not {@code null} |
57449 | 255 |
* |
58129 | 256 |
* @return {@code true} if the action was unregistered, {@code false} |
257 |
* otherwise |
|
57361 | 258 |
* |
259 |
* @see #onEvent(Consumer) |
|
260 |
* @see #onEvent(String, Consumer) |
|
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
261 |
* @see #onFlush(Runnable) |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
262 |
* @see #onClose(Runnable) |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
263 |
* @see #onError(Consumer) |
57361 | 264 |
*/ |
265 |
boolean remove(Object action); |
|
266 |
||
267 |
/** |
|
57449 | 268 |
* Specifies that the event object in an {@link #onEvent(Consumer)} action |
58129 | 269 |
* can be reused. |
57376 | 270 |
* <p> |
58129 | 271 |
* If reuse is set to {@code true), an action should not keep a reference |
272 |
* to the event object after the action has completed. |
|
57380
6a7e7743b82f
setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents:
57377
diff
changeset
|
273 |
* |
58129 | 274 |
* @param reuse {@code true} if an event object can be reused, {@code false} |
275 |
* otherwise |
|
57376 | 276 |
*/ |
58129 | 277 |
void setReuse(boolean reuse); |
57376 | 278 |
|
279 |
/** |
|
57449 | 280 |
* Specifies that events arrives in chronological order, sorted by the time |
58129 | 281 |
* they were committed to the stream. |
57380
6a7e7743b82f
setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents:
57377
diff
changeset
|
282 |
* |
57449 | 283 |
* @param ordered if event objects arrive in chronological order to |
284 |
* {@code #onEvent(Consumer)} |
|
57380
6a7e7743b82f
setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents:
57377
diff
changeset
|
285 |
*/ |
58129 | 286 |
void setOrdered(boolean ordered); |
57380
6a7e7743b82f
setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents:
57377
diff
changeset
|
287 |
|
6a7e7743b82f
setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents:
57377
diff
changeset
|
288 |
/** |
58129 | 289 |
* Specifies the start time of the stream. |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
290 |
* <p> |
58129 | 291 |
* The start time must be set before starting the stream |
57449 | 292 |
* |
293 |
* @param startTime the start time, not {@code null} |
|
294 |
* |
|
58129 | 295 |
* @throws IllegalStateException if the stream is already started |
296 |
* |
|
297 |
* @see #start() |
|
298 |
* @see #startAsync() |
|
57449 | 299 |
*/ |
58129 | 300 |
void setStartTime(Instant startTime); |
57449 | 301 |
|
302 |
/** |
|
58129 | 303 |
* Specifies the end time of the stream. |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
304 |
* <p> |
58129 | 305 |
* The end time must be set before starting the stream. |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
306 |
* <p> |
58129 | 307 |
* At end time, the stream is closed. |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
308 |
* |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
309 |
* @param endTime the end time, not {@code null} |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
310 |
* |
58129 | 311 |
* @throws IllegalStateException if the stream is already started |
312 |
* |
|
313 |
* @see #start() |
|
314 |
* @see #startAsync() |
|
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
315 |
*/ |
58129 | 316 |
void setEndTime(Instant endTime); |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
317 |
|
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
318 |
/** |
58129 | 319 |
* Start processing of actions. |
57361 | 320 |
* <p> |
58129 | 321 |
* Actions are performed in the current thread. |
57361 | 322 |
* |
58129 | 323 |
* @throws IllegalStateException if the stream is already started or closed |
57361 | 324 |
*/ |
325 |
void start(); |
|
326 |
||
327 |
/** |
|
58129 | 328 |
* Start asynchronous processing of actions. |
57361 | 329 |
* <p> |
58129 | 330 |
* Actions are performed in a single separate thread. |
57361 | 331 |
* |
58129 | 332 |
* @throws IllegalStateException if the stream is already started or closed |
57361 | 333 |
*/ |
334 |
void startAsync(); |
|
335 |
||
336 |
/** |
|
58129 | 337 |
* Blocks until all actions are completed, or the stream is closed, or the |
338 |
* timeout occurs, or the current thread is interrupted, whichever happens |
|
339 |
* first. |
|
57361 | 340 |
* |
341 |
* @param timeout the maximum time to wait, not {@code null} |
|
342 |
* |
|
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
343 |
* @throws IllegalArgumentException if timeout is negative |
58129 | 344 |
* @throws InterruptedException if interrupted while waiting |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
345 |
* |
57361 | 346 |
* @see #start() |
347 |
* @see #startAsync() |
|
58129 | 348 |
* @see Thread#interrupt() |
57361 | 349 |
*/ |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
350 |
void awaitTermination(Duration timeout) throws InterruptedException; |
57361 | 351 |
|
352 |
/** |
|
58129 | 353 |
* Blocks until all actions are completed, or the stream is closed, or the |
354 |
* current thread is interrupted, whichever happens first. |
|
57361 | 355 |
* |
58129 | 356 |
* @throws InterruptedException if interrupted while waiting |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
357 |
* |
57361 | 358 |
* @see #start() |
359 |
* @see #startAsync() |
|
58129 | 360 |
* @see Thread#interrupt() |
57361 | 361 |
*/ |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
362 |
void awaitTermination() throws InterruptedException; |
58180 | 363 |
} |