1 /* 2 * Copyright (c) 2001, 2016, 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.io.IOException; 29 import java.nio.channels.*; 30 import java.nio.channels.spi.*; 31 import java.util.*; 32 33 34 /** 35 * An implementation of Selector for Solaris. 36 */ 37 38 class PollSelectorImpl 39 extends AbstractPollSelectorImpl 40 { 41 42 // File descriptors used for interrupt 43 private int fd0; 44 private int fd1; 45 46 // Lock for interrupt triggering and clearing 47 private Object interruptLock = new Object(); 48 private boolean interruptTriggered = false; 49 50 /** 51 * Package private constructor called by factory method in 52 * the abstract superclass Selector. 53 */ 54 PollSelectorImpl(SelectorProvider sp) { 55 super(sp, 1, 1); 56 long pipeFds = IOUtil.makePipe(false); 57 fd0 = (int) (pipeFds >>> 32); 58 fd1 = (int) pipeFds; 59 try { 60 pollWrapper = new PollArrayWrapper(INIT_CAP); 61 pollWrapper.initInterrupt(fd0, fd1); 62 channelArray = new SelectionKeyImpl[INIT_CAP]; 63 } catch (Throwable t) { 64 try { 65 FileDispatcherImpl.closeIntFD(fd0); 66 } catch (IOException ioe0) { 67 t.addSuppressed(ioe0); | 1 /* 2 * Copyright (c) 2001, 2018, 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.io.IOException; 29 import java.nio.channels.*; 30 import java.nio.channels.spi.*; 31 32 33 /** 34 * An implementation of Selector for Solaris. 35 */ 36 37 class PollSelectorImpl 38 extends AbstractPollSelectorImpl 39 { 40 41 // File descriptors used for interrupt 42 private int fd0; 43 private int fd1; 44 45 // Lock for interrupt triggering and clearing 46 private final Object interruptLock = new Object(); 47 private boolean interruptTriggered = false; 48 49 /** 50 * Package private constructor called by factory method in 51 * the abstract superclass Selector. 52 */ 53 PollSelectorImpl(SelectorProvider sp) { 54 super(sp, 1, 1); 55 long pipeFds = IOUtil.makePipe(false); 56 fd0 = (int) (pipeFds >>> 32); 57 fd1 = (int) pipeFds; 58 try { 59 pollWrapper = new PollArrayWrapper(INIT_CAP); 60 pollWrapper.initInterrupt(fd0, fd1); 61 channelArray = new SelectionKeyImpl[INIT_CAP]; 62 } catch (Throwable t) { 63 try { 64 FileDispatcherImpl.closeIntFD(fd0); 65 } catch (IOException ioe0) { 66 t.addSuppressed(ioe0); |