author | mgronlun |
Wed, 18 Sep 2019 18:15:29 +0200 | |
branch | JEP-349-branch |
changeset 58213 | 354c7790c548 |
parent 58212 | 412d8e77f931 |
child 58357 | fe78b5a87287 |
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> |
58213 | 54 |
* By default, the same {@code RecordedEvent} object can be used to |
55 |
* represent two or more distinct events. That object can be delivered |
|
58212 | 56 |
* multiple times to the same action as well as to other actions. To use an |
57 |
* event object after the action is completed, the |
|
58 |
* {@link #setReuse(boolean)} method should be set to {@code false} so a |
|
58129 | 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 |
|
58212 | 78 |
* awaitTermination {@link #awaitTermination()} or the |
58129 | 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 |
* }); |
|
107 |
* es.onEvent("jdk.GarbageCollection", event -> { |
|
108 |
* System.out.println("Garbage collection: " + event.getLong("gcId")); |
|
109 |
* System.out.println(" Cause: " + event.getString("cause")); |
|
110 |
* System.out.println(" Total pause: " + event.getDuration("sumOfPauses")); |
|
111 |
* System.out.println(" Longest pause: " + event.getDuration("longestPause")); |
|
112 |
* System.out.println(); |
|
113 |
* }); |
|
114 |
* es.start(); |
|
115 |
* } |
|
116 |
* </code> |
|
117 |
* </pre> |
|
58129 | 118 |
* <p> |
58152 | 119 |
* To start recording together with the stream, see {@link RecordingStream}. |
58129 | 120 |
* |
58200 | 121 |
* @since 14 |
57361 | 122 |
*/ |
123 |
public interface EventStream extends AutoCloseable { |
|
124 |
/** |
|
58129 | 125 |
* Creates a stream from the repository of the current Java Virtual Machine |
126 |
* (JVM). |
|
57627 | 127 |
* <p> |
128 |
* By default, the stream starts with the next event flushed by Flight |
|
129 |
* Recorder. |
|
130 |
* |
|
131 |
* @return an event stream, not {@code null} |
|
132 |
* |
|
133 |
* @throws IOException if a stream can't be opened, or an I/O error occurs |
|
134 |
* 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
|
135 |
* |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
136 |
* @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
|
137 |
* does not have |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
138 |
* {@code FlightRecorderPermission("accessFlightRecorder")} |
57627 | 139 |
*/ |
140 |
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
|
141 |
Utils.checkAccessFlightRecorder(); |
57717
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
142 |
return new EventDirectoryStream(AccessController.getContext(), null, SecuritySupport.PRIVILIGED, false); |
57627 | 143 |
} |
144 |
||
145 |
/** |
|
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
146 |
* Creates an event stream from a disk repository. |
57449 | 147 |
* <p> |
57627 | 148 |
* By default, the stream starts with the next event flushed by Flight |
149 |
* Recorder. |
|
57361 | 150 |
* |
151 |
* @param directory location of the disk repository, not {@code null} |
|
57449 | 152 |
* |
57361 | 153 |
* @return an event stream, not {@code null} |
57449 | 154 |
* |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
155 |
* @throws IOException if a stream can't be opened, or an I/O error occurs |
57627 | 156 |
* 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
|
157 |
* |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
158 |
* @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
|
159 |
* {@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
|
160 |
* files in the directory. |
57361 | 161 |
*/ |
162 |
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
|
163 |
Objects.nonNull(directory); |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
164 |
AccessControlContext acc = AccessController.getContext(); |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
165 |
return new EventDirectoryStream(acc, directory, FileAccess.UNPRIVILIGED, false); |
57361 | 166 |
} |
167 |
||
168 |
/** |
|
57449 | 169 |
* Creates an event stream from a file. |
170 |
* <p> |
|
57452
6fabe73e5d9a
Reduced allocation pressure. Fix getValue for startTime and duration
egahlin
parents:
57449
diff
changeset
|
171 |
* By default, the stream starts with the first event in the file. |
57361 | 172 |
* |
173 |
* @param file location of the file, not {@code null} |
|
57449 | 174 |
* |
57361 | 175 |
* @return an event stream, not {@code null} |
57372
50ca040843ea
Prepare infrastructure for multiple implementations of EventStream
egahlin
parents:
57361
diff
changeset
|
176 |
* |
58129 | 177 |
* @throws IOException if the file can't be opened, or an I/O error occurs |
57376 | 178 |
* during reading |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
179 |
* |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
180 |
* @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
|
181 |
* {@code checkRead} method denies read access to the file |
57361 | 182 |
*/ |
58197 | 183 |
static EventStream openFile(Path file) throws IOException { |
57985 | 184 |
return new EventFileStream(AccessController.getContext(), file); |
57372
50ca040843ea
Prepare infrastructure for multiple implementations of EventStream
egahlin
parents:
57361
diff
changeset
|
185 |
} |
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 |
/** |
58129 | 188 |
* Registers an action to perform on all events in the stream. |
57361 | 189 |
* |
58129 | 190 |
* @param action an action to perform on each {@code RecordedEvent}, not |
191 |
* {@code null} |
|
57361 | 192 |
*/ |
193 |
void onEvent(Consumer<RecordedEvent> action); |
|
194 |
||
195 |
/** |
|
58129 | 196 |
* Registers an action to perform on all events matching a name. |
57361 | 197 |
* |
198 |
* @param eventName the name of the event, not {@code null} |
|
57449 | 199 |
* |
58129 | 200 |
* @param action an action to perform on each {@code RecordedEvent} matching |
201 |
* the event name, not {@code null} |
|
57361 | 202 |
*/ |
203 |
void onEvent(String eventName, Consumer<RecordedEvent> action); |
|
204 |
||
205 |
/** |
|
58129 | 206 |
* Registers an action to perform after the stream has been flushed. |
57361 | 207 |
* |
58129 | 208 |
* @param action an action to perform after the stream has been |
209 |
* flushed, not {@code null} |
|
57361 | 210 |
*/ |
211 |
void onFlush(Runnable action); |
|
212 |
||
213 |
/** |
|
58129 | 214 |
* Registers an action to perform if an exception occurs. |
57971 | 215 |
* <p> |
58129 | 216 |
* if an action is not registered, an exception stack trace is printed to |
217 |
* standard error. |
|
57971 | 218 |
* <p> |
58129 | 219 |
* Registering an action overrides the default behavior. If multiple actions |
220 |
* have been registered, they are performed in the order of registration. |
|
221 |
* <p> |
|
222 |
* If this method itself throws an exception, resulting behavior is |
|
223 |
* undefined. |
|
57971 | 224 |
* |
58129 | 225 |
* @param action an action to perform if an exception occurs, not |
57971 | 226 |
* {@code null} |
227 |
*/ |
|
228 |
void onError(Consumer<Throwable> action); |
|
229 |
||
230 |
/** |
|
58129 | 231 |
* Registers an action to perform when the stream is closed. |
57449 | 232 |
* <p> |
58129 | 233 |
* If the stream is already closed, the action will be performed immediately |
57449 | 234 |
* in the current thread. |
57361 | 235 |
* |
58129 | 236 |
* @param action an action to perform after the stream is closed, not |
237 |
* {@code null} |
|
238 |
* @see #close() |
|
57361 | 239 |
*/ |
240 |
void onClose(Runnable action); |
|
241 |
||
242 |
/** |
|
58129 | 243 |
* Releases all resources associated with this stream. |
57361 | 244 |
*/ |
245 |
void close(); |
|
246 |
||
247 |
/** |
|
58129 | 248 |
* Unregisters an action. |
57361 | 249 |
* <p> |
58129 | 250 |
* If the action has been registered multiple times, all instances are |
251 |
* unregistered. |
|
57361 | 252 |
* |
58129 | 253 |
* @param action the action to unregister, not {@code null} |
57449 | 254 |
* |
58129 | 255 |
* @return {@code true} if the action was unregistered, {@code false} |
256 |
* otherwise |
|
57361 | 257 |
* |
258 |
* @see #onEvent(Consumer) |
|
259 |
* @see #onEvent(String, Consumer) |
|
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
260 |
* @see #onFlush(Runnable) |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
261 |
* @see #onClose(Runnable) |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
262 |
* @see #onError(Consumer) |
57361 | 263 |
*/ |
264 |
boolean remove(Object action); |
|
265 |
||
266 |
/** |
|
57449 | 267 |
* Specifies that the event object in an {@link #onEvent(Consumer)} action |
58129 | 268 |
* can be reused. |
57376 | 269 |
* <p> |
58129 | 270 |
* If reuse is set to {@code true), an action should not keep a reference |
271 |
* 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
|
272 |
* |
58129 | 273 |
* @param reuse {@code true} if an event object can be reused, {@code false} |
274 |
* otherwise |
|
57376 | 275 |
*/ |
58129 | 276 |
void setReuse(boolean reuse); |
57376 | 277 |
|
278 |
/** |
|
57449 | 279 |
* Specifies that events arrives in chronological order, sorted by the time |
58129 | 280 |
* they were committed to the stream. |
57380
6a7e7743b82f
setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents:
57377
diff
changeset
|
281 |
* |
57449 | 282 |
* @param ordered if event objects arrive in chronological order to |
283 |
* {@code #onEvent(Consumer)} |
|
57380
6a7e7743b82f
setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents:
57377
diff
changeset
|
284 |
*/ |
58129 | 285 |
void setOrdered(boolean ordered); |
57380
6a7e7743b82f
setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents:
57377
diff
changeset
|
286 |
|
6a7e7743b82f
setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents:
57377
diff
changeset
|
287 |
/** |
58129 | 288 |
* 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
|
289 |
* <p> |
58129 | 290 |
* The start time must be set before starting the stream |
57449 | 291 |
* |
292 |
* @param startTime the start time, not {@code null} |
|
293 |
* |
|
58129 | 294 |
* @throws IllegalStateException if the stream is already started |
295 |
* |
|
296 |
* @see #start() |
|
297 |
* @see #startAsync() |
|
57449 | 298 |
*/ |
58129 | 299 |
void setStartTime(Instant startTime); |
57449 | 300 |
|
301 |
/** |
|
58129 | 302 |
* 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
|
303 |
* <p> |
58129 | 304 |
* 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
|
305 |
* <p> |
58129 | 306 |
* 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
|
307 |
* |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
308 |
* @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
|
309 |
* |
58129 | 310 |
* @throws IllegalStateException if the stream is already started |
311 |
* |
|
312 |
* @see #start() |
|
313 |
* @see #startAsync() |
|
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
314 |
*/ |
58129 | 315 |
void setEndTime(Instant endTime); |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
316 |
|
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57627
diff
changeset
|
317 |
/** |
58129 | 318 |
* Start processing of actions. |
57361 | 319 |
* <p> |
58129 | 320 |
* Actions are performed in the current thread. |
57361 | 321 |
* |
58129 | 322 |
* @throws IllegalStateException if the stream is already started or closed |
57361 | 323 |
*/ |
324 |
void start(); |
|
325 |
||
326 |
/** |
|
58129 | 327 |
* Start asynchronous processing of actions. |
57361 | 328 |
* <p> |
58129 | 329 |
* Actions are performed in a single separate thread. |
57361 | 330 |
* |
58129 | 331 |
* @throws IllegalStateException if the stream is already started or closed |
57361 | 332 |
*/ |
333 |
void startAsync(); |
|
334 |
||
335 |
/** |
|
58129 | 336 |
* Blocks until all actions are completed, or the stream is closed, or the |
337 |
* timeout occurs, or the current thread is interrupted, whichever happens |
|
338 |
* first. |
|
57361 | 339 |
* |
340 |
* @param timeout the maximum time to wait, not {@code null} |
|
341 |
* |
|
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
342 |
* @throws IllegalArgumentException if timeout is negative |
58129 | 343 |
* @throws InterruptedException if interrupted while waiting |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
344 |
* |
57361 | 345 |
* @see #start() |
346 |
* @see #startAsync() |
|
58129 | 347 |
* @see Thread#interrupt() |
57361 | 348 |
*/ |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
349 |
void awaitTermination(Duration timeout) throws InterruptedException; |
57361 | 350 |
|
351 |
/** |
|
58129 | 352 |
* Blocks until all actions are completed, or the stream is closed, or the |
353 |
* current thread is interrupted, whichever happens first. |
|
57361 | 354 |
* |
58129 | 355 |
* @throws InterruptedException if interrupted while waiting |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
356 |
* |
57361 | 357 |
* @see #start() |
358 |
* @see #startAsync() |
|
58129 | 359 |
* @see Thread#interrupt() |
57361 | 360 |
*/ |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
361 |
void awaitTermination() throws InterruptedException; |
58180 | 362 |
} |