author | rriggs |
Fri, 01 Dec 2017 16:40:08 -0500 | |
changeset 48224 | be0df5ab3093 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
11823
diff
changeset
|
2 |
* Copyright (c) 2001, 2012, 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 |
||
28 |
||
29 |
/** |
|
30 |
* Manipulates a native array of pollfd structs. |
|
31 |
* |
|
32 |
* @author Mike McCloskey |
|
33 |
* @since 1.4 |
|
34 |
*/ |
|
35 |
||
11823
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
36 |
public abstract class AbstractPollArrayWrapper { |
2 | 37 |
|
38 |
// Miscellaneous constants |
|
39 |
static final short SIZE_POLLFD = 8; |
|
40 |
static final short FD_OFFSET = 0; |
|
41 |
static final short EVENT_OFFSET = 4; |
|
42 |
static final short REVENT_OFFSET = 6; |
|
43 |
||
44 |
// The poll fd array |
|
45 |
protected AllocatedNativeObject pollArray; |
|
46 |
||
47 |
// Number of valid entries in the pollArray |
|
48 |
protected int totalChannels = 0; |
|
49 |
||
50 |
// Base address of the native pollArray |
|
51 |
protected long pollArrayAddress; |
|
52 |
||
53 |
// Access methods for fd structures |
|
54 |
int getEventOps(int i) { |
|
55 |
int offset = SIZE_POLLFD * i + EVENT_OFFSET; |
|
56 |
return pollArray.getShort(offset); |
|
57 |
} |
|
58 |
||
59 |
int getReventOps(int i) { |
|
60 |
int offset = SIZE_POLLFD * i + REVENT_OFFSET; |
|
61 |
return pollArray.getShort(offset); |
|
62 |
} |
|
63 |
||
64 |
int getDescriptor(int i) { |
|
65 |
int offset = SIZE_POLLFD * i + FD_OFFSET; |
|
66 |
return pollArray.getInt(offset); |
|
67 |
} |
|
68 |
||
69 |
void putEventOps(int i, int event) { |
|
70 |
int offset = SIZE_POLLFD * i + EVENT_OFFSET; |
|
71 |
pollArray.putShort(offset, (short)event); |
|
72 |
} |
|
73 |
||
74 |
void putReventOps(int i, int revent) { |
|
75 |
int offset = SIZE_POLLFD * i + REVENT_OFFSET; |
|
76 |
pollArray.putShort(offset, (short)revent); |
|
77 |
} |
|
78 |
||
79 |
void putDescriptor(int i, int fd) { |
|
80 |
int offset = SIZE_POLLFD * i + FD_OFFSET; |
|
81 |
pollArray.putInt(offset, fd); |
|
82 |
} |
|
83 |
||
84 |
} |