19
19
import java .util .function .BiConsumer ;
20
20
21
21
/**
22
- * A collection of all the 3 main pipes used in stdio: STDIN, STDOUT and STDERR. As working with the named pipes is usually carried out
23
- * asynchronously, this collection also provides means to initiate and handle the close() event. A close() initiator calls the
24
- * {@link #close(int, long)} method expressing its intent to close the communication channel. Handlers are notified of this intent and
25
- * its up to the handlers to decide what's to be done next. Calling {@link #close(int, long)} does not close the streams or do anything
26
- * else besides notifying the handlers.
22
+ * A collection of all the 3 main pipes used in stdio: STDIN, STDOUT and STDERR. As working with the
23
+ * named pipes is usually carried out asynchronously, this collection also provides means to
24
+ * initiate and handle the close() event. A close() initiator calls the {@link #close(int, long)}
25
+ * method expressing its intent to close the communication channel. Handlers are notified of this
26
+ * intent and its up to the handlers to decide what's to be done next. Calling {@link #close(int,
27
+ * long)} does not close the streams or do anything else besides notifying the handlers.
27
28
*/
28
29
public class IOTrio {
29
30
private InputStream stdout ;
@@ -62,20 +63,22 @@ public void setStdin(OutputStream stdin) {
62
63
/**
63
64
* Capture the CLOSE intent and handle it accordingly.
64
65
*
65
- * @param handler the handler that's invoked when someone intends to close this communication. Multiple handlers can be registered
66
+ * @param handler the handler that's invoked when someone intends to close this communication.
67
+ * Multiple handlers can be registered
66
68
*/
67
69
public void onClose (BiConsumer <Integer , Long > handler ) {
68
70
closeHandlers .add (handler );
69
71
}
70
72
71
73
/**
72
- * Express an intent to close this communication. This intent will be relayed to all the registered handlers and it's up to them what
73
- * to do with it.
74
- * @param code proposed exit code
75
- * @param timeout time in milliseconds given to terminate this communication. Negative timeout means no timeout (i.e. wait for as long
76
- * as it takes). 0 means "stop it now".
74
+ * Express an intent to close this communication. This intent will be relayed to all the
75
+ * registered handlers and it's up to them what to do with it.
76
+ *
77
+ * @param code proposed exit code
78
+ * @param timeout time in milliseconds given to terminate this communication. Negative timeout
79
+ * means no timeout (i.e. wait for as long as it takes). 0 means "stop it now".
77
80
*/
78
81
public void close (int code , long timeout ) {
79
82
closeHandlers .forEach (handler -> handler .accept (code , timeout ));
80
83
}
81
- }
84
+ }
0 commit comments