Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.base/share/classes/sun/nio/ch/SelChImpl.java
41159 views
1
/*
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.
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 sun.nio.ch;
27
28
import java.nio.channels.Channel;
29
import java.io.FileDescriptor;
30
import java.io.IOException;
31
32
import static java.util.concurrent.TimeUnit.NANOSECONDS;
33
34
/**
35
* An interface that allows translation (and more!).
36
*
37
* @since 1.4
38
*/
39
40
public interface SelChImpl extends Channel {
41
42
FileDescriptor getFD();
43
44
int getFDVal();
45
46
/**
47
* Adds the specified ops if present in interestOps. The specified
48
* ops are turned on without affecting the other ops.
49
*
50
* @return true iff the new value of sk.readyOps() set by this method
51
* contains at least one bit that the previous value did not
52
* contain
53
*/
54
boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl ski);
55
56
/**
57
* Sets the specified ops if present in interestOps. The specified
58
* ops are turned on, and all other ops are turned off.
59
*
60
* @return true iff the new value of sk.readyOps() set by this method
61
* contains at least one bit that the previous value did not
62
* contain
63
*/
64
boolean translateAndSetReadyOps(int ops, SelectionKeyImpl ski);
65
66
/**
67
* Translates an interest operation set into a native event set
68
*/
69
int translateInterestOps(int ops);
70
71
void kill() throws IOException;
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
109
}
110
111