author | chegar |
Fri, 18 Oct 2019 21:25:01 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58697 | e3ff12d14d43 |
parent 54620 | 13b67c1420b8 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
2 |
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.nio.ch; |
|
27 |
||
2433
9f0ab7f726b8
6693490: (se) select throws "File exists" IOException under load (lnx)
alanb
parents:
2
diff
changeset
|
28 |
import java.nio.channels.Channel; |
2 | 29 |
import java.io.FileDescriptor; |
30 |
import java.io.IOException; |
|
31 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
32 |
import static java.util.concurrent.TimeUnit.NANOSECONDS; |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
33 |
|
2 | 34 |
/** |
35 |
* An interface that allows translation (and more!). |
|
36 |
* |
|
37 |
* @since 1.4 |
|
38 |
*/ |
|
39 |
||
11823
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
40 |
public interface SelChImpl extends Channel { |
2 | 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 |
*/ |
|
49526 | 54 |
boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl ski); |
2 | 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 |
*/ |
|
49526 | 64 |
boolean translateAndSetReadyOps(int ops, SelectionKeyImpl ski); |
2 | 65 |
|
49493 | 66 |
/** |
67 |
* Translates an interest operation set into a native event set |
|
68 |
*/ |
|
69 |
int translateInterestOps(int ops); |
|
2 | 70 |
|
71 |
void kill() throws IOException; |
|
72 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
73 |
/** |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
74 |
* Disables the current thread for scheduling purposes until this |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
75 |
* channel is ready for I/O, or asynchronously closed, for up to the |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
76 |
* specified waiting time. |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
77 |
* |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
78 |
* <p> This method does <em>not</em> report which of these caused the |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
79 |
* method to return. Callers should re-check the conditions which caused |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
80 |
* the thread to park. |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
81 |
* |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
82 |
* @param event the event to poll |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
83 |
* @param nanos the timeout to wait; {@code <= 0} to wait indefinitely |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
84 |
*/ |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
85 |
default void park(int event, long nanos) throws IOException { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
86 |
long millis; |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
87 |
if (nanos <= 0) { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
88 |
millis = -1; |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
89 |
} else { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
90 |
millis = NANOSECONDS.toMillis(nanos); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
91 |
} |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
92 |
Net.poll(getFD(), event, millis); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
93 |
} |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
94 |
|
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
95 |
/** |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
96 |
* Disables the current thread for scheduling purposes until this |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
97 |
* channel is ready for I/O, or asynchronously closed. |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
98 |
* |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
99 |
* <p> This method does <em>not</em> report which of these caused the |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
100 |
* method to return. Callers should re-check the conditions which caused |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
101 |
* the thread to park. |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
102 |
* |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
103 |
* @param event the event to poll |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
104 |
*/ |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
105 |
default void park(int event) throws IOException { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
106 |
park(event, 0L); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
107 |
} |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
49526
diff
changeset
|
108 |
|
2 | 109 |
} |