Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/nio/ch/AbstractPollArrayWrapper.java
38918 views
/*1* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.nio.ch;2627import sun.misc.*;282930/**31* Manipulates a native array of pollfd structs.32*33* @author Mike McCloskey34* @since 1.435*/3637public abstract class AbstractPollArrayWrapper {3839// Miscellaneous constants40static final short SIZE_POLLFD = 8;41static final short FD_OFFSET = 0;42static final short EVENT_OFFSET = 4;43static final short REVENT_OFFSET = 6;4445// The poll fd array46protected AllocatedNativeObject pollArray;4748// Number of valid entries in the pollArray49protected int totalChannels = 0;5051// Base address of the native pollArray52protected long pollArrayAddress;5354// Access methods for fd structures55int getEventOps(int i) {56int offset = SIZE_POLLFD * i + EVENT_OFFSET;57return pollArray.getShort(offset);58}5960int getReventOps(int i) {61int offset = SIZE_POLLFD * i + REVENT_OFFSET;62return pollArray.getShort(offset);63}6465int getDescriptor(int i) {66int offset = SIZE_POLLFD * i + FD_OFFSET;67return pollArray.getInt(offset);68}6970void putEventOps(int i, int event) {71int offset = SIZE_POLLFD * i + EVENT_OFFSET;72pollArray.putShort(offset, (short)event);73}7475void putReventOps(int i, int revent) {76int offset = SIZE_POLLFD * i + REVENT_OFFSET;77pollArray.putShort(offset, (short)revent);78}7980void putDescriptor(int i, int fd) {81int offset = SIZE_POLLFD * i + FD_OFFSET;82pollArray.putInt(offset, fd);83}8485}868788