equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
26 package sun.nio.ch; |
26 package sun.nio.ch; |
27 |
27 |
28 import java.nio.channels.Channel; |
28 import java.nio.channels.Channel; |
29 import java.io.FileDescriptor; |
29 import java.io.FileDescriptor; |
30 import java.io.IOException; |
30 import java.io.IOException; |
|
31 |
|
32 import static java.util.concurrent.TimeUnit.NANOSECONDS; |
31 |
33 |
32 /** |
34 /** |
33 * An interface that allows translation (and more!). |
35 * An interface that allows translation (and more!). |
34 * |
36 * |
35 * @since 1.4 |
37 * @since 1.4 |
66 */ |
68 */ |
67 int translateInterestOps(int ops); |
69 int translateInterestOps(int ops); |
68 |
70 |
69 void kill() throws IOException; |
71 void kill() throws IOException; |
70 |
72 |
|
73 /** |
|
74 * Disables the current thread for scheduling purposes until this |
|
75 * channel is ready for I/O, or asynchronously closed, for up to the |
|
76 * specified waiting time. |
|
77 * |
|
78 * <p> This method does <em>not</em> report which of these caused the |
|
79 * method to return. Callers should re-check the conditions which caused |
|
80 * the thread to park. |
|
81 * |
|
82 * @param event the event to poll |
|
83 * @param nanos the timeout to wait; {@code <= 0} to wait indefinitely |
|
84 */ |
|
85 default void park(int event, long nanos) throws IOException { |
|
86 long millis; |
|
87 if (nanos <= 0) { |
|
88 millis = -1; |
|
89 } else { |
|
90 millis = NANOSECONDS.toMillis(nanos); |
|
91 } |
|
92 Net.poll(getFD(), event, millis); |
|
93 } |
|
94 |
|
95 /** |
|
96 * Disables the current thread for scheduling purposes until this |
|
97 * channel is ready for I/O, or asynchronously closed. |
|
98 * |
|
99 * <p> This method does <em>not</em> report which of these caused the |
|
100 * method to return. Callers should re-check the conditions which caused |
|
101 * the thread to park. |
|
102 * |
|
103 * @param event the event to poll |
|
104 */ |
|
105 default void park(int event) throws IOException { |
|
106 park(event, 0L); |
|
107 } |
|
108 |
71 } |
109 } |