|
20 | 20 |
|
21 | 21 | import java.nio.ByteBuffer;
|
22 | 22 |
|
23 |
| -/** |
24 |
| - * An asynchronous channel that can write bytes. |
25 |
| - * |
26 |
| - * @since 3.0 |
27 |
| - */ |
| 23 | +// An asynchronous channel that can write bytes. |
28 | 24 | interface AsyncWritableByteChannel {
|
29 |
| - /** |
30 |
| - * Writes a sequence of bytes to this channel from the given buffer. |
31 |
| - * |
32 |
| - * <p> This method initiates an asynchronous write operation to write a |
33 |
| - * sequence of bytes to this channel from the given buffer. The {@code |
34 |
| - * handler} parameter is a completion handler that is invoked when the write |
35 |
| - * operation completes (or fails). The result passed to the completion |
36 |
| - * handler is the number of bytes written. |
37 |
| - * |
38 |
| - * <p> The write operation may write up to <i>r</i> bytes to the channel, |
39 |
| - * where <i>r</i> is the number of bytes remaining in the buffer, that is, |
40 |
| - * {@code src.remaining()} at the time that the write is attempted. Where |
41 |
| - * <i>r</i> is 0, the write operation completes immediately with a result of |
42 |
| - * {@code 0} without initiating an I/O operation. |
43 |
| - * |
44 |
| - * <p> Suppose that a byte sequence of length <i>n</i> is written, where |
45 |
| - * <tt>0</tt> <tt><</tt> <i>n</i> <tt><=</tt> <i>r</i>. |
46 |
| - * This byte sequence will be transferred from the buffer starting at index |
47 |
| - * <i>p</i>, where <i>p</i> is the buffer's position at the moment the |
48 |
| - * write is performed; the index of the last byte written will be |
49 |
| - * <i>p</i> <tt>+</tt> <i>n</i> <tt>-</tt> <tt>1</tt>. |
50 |
| - * Upon completion the buffer's position will be equal to |
51 |
| - * <i>p</i> <tt>+</tt> <i>n</i>; its limit will not have changed. |
52 |
| - * |
53 |
| - * <p> Buffers are not safe for use by multiple concurrent threads so care |
54 |
| - * should be taken to not access the buffer until the operation has |
55 |
| - * completed. |
56 |
| - * |
57 |
| - * <p> This method may be invoked at any time. Some channel types may not |
58 |
| - * allow more than one write to be outstanding at any given time. If a thread |
59 |
| - * initiates a write operation before a previous write operation has |
60 |
| - * completed then a {@link java.nio.channels.WritePendingException} will be thrown. |
61 |
| - * |
62 |
| - * @param src |
63 |
| - * The buffer from which bytes are to be retrieved |
64 |
| - * @param handler |
65 |
| - * The completion handler object |
66 |
| - * |
67 |
| - * @throws java.nio.channels.WritePendingException |
68 |
| - * If the channel does not allow more than one write to be outstanding |
69 |
| - * and a previous write has not completed |
70 |
| - * @throws java.nio.channels.ShutdownChannelGroupException |
71 |
| - * If the channel is associated with a {@link java.nio.channels.AsynchronousChannelGroup |
72 |
| - * group} that has terminated |
73 |
| - */ |
| 25 | + // Writes a sequence of bytes to this channel from the given buffer. |
| 26 | + // |
| 27 | + // This method initiates an asynchronous write operation to write a |
| 28 | + // sequence of bytes to this channel from the given buffer. The |
| 29 | + // handler parameter is a completion handler that is invoked when the write |
| 30 | + // operation completes (or fails). The result passed to the completion |
| 31 | + // handler is the number of bytes written. |
| 32 | + // |
| 33 | + // The write operation may write up to r bytes to the channel, |
| 34 | + // where r is the number of bytes remaining in the buffer, that is, |
| 35 | + // src.remaining() at the time that the write is attempted. Where |
| 36 | + // r is 0, the write operation completes immediately with a result of |
| 37 | + // 0 without initiating an I/O operation. |
| 38 | + // |
| 39 | + // Suppose that a byte sequence of length n is written, where 0 < n <= r. |
| 40 | + // This byte sequence will be transferred from the buffer starting at index |
| 41 | + // p, where p is the buffer's position at the moment the write is performed; |
| 42 | + // the index of the last byte written will be p + n - 1}. |
| 43 | + // Upon completion the buffer's position will be equal to p + n; |
| 44 | + // its limit will not have changed. |
| 45 | + // |
| 46 | + // Buffers are not safe for use by multiple concurrent threads so care |
| 47 | + // should be taken to not access the buffer until the operation has |
| 48 | + // completed. |
| 49 | + // |
| 50 | + // This method may be invoked at any time. Some channel types may not |
| 51 | + // allow more than one write to be outstanding at any given time. If a thread |
| 52 | + // initiates a write operation before a previous write operation has |
| 53 | + // completed then a java.nio.channels.WritePendingException will be thrown. |
74 | 54 | void write(ByteBuffer src, AsyncCompletionHandler<Void> handler);
|
75 | 55 | }
|
0 commit comments