src/jdk.net/linux/classes/jdk/internal/net/rdma/RdmaPollSelectorProvider.java
branchrsocket-branch
changeset 57115 512e7cc6ccce
child 57120 64301e5a0da8
equal deleted inserted replaced
53485:b743968ad646 57115:512e7cc6ccce
       
     1 /*
       
     2  * Copyright (c) 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 jdk.internal.net.rdma;
       
    27 
       
    28 import java.io.IOException;
       
    29 import java.net.ProtocolFamily;
       
    30 import java.nio.channels.DatagramChannel;
       
    31 import java.nio.channels.Pipe;
       
    32 import java.nio.channels.ServerSocketChannel;
       
    33 import java.nio.channels.SocketChannel;
       
    34 import java.nio.channels.spi.AbstractSelector;
       
    35 import java.nio.channels.spi.SelectorProvider;
       
    36 import sun.nio.ch.SelectorProviderImpl;
       
    37 import java.security.AccessController;
       
    38 import java.security.PrivilegedAction;
       
    39 
       
    40 public class RdmaPollSelectorProvider
       
    41     extends SelectorProvider
       
    42 {
       
    43     private static final Object lock = new Object();
       
    44     private static SelectorProvider provider = null;
       
    45 
       
    46     public static SelectorProvider provider() {
       
    47         synchronized (lock) {
       
    48             if (provider != null)
       
    49                 return provider;
       
    50             return AccessController.doPrivileged(
       
    51                 new PrivilegedAction<>() {
       
    52                     public SelectorProvider run() {
       
    53                             provider = new RdmaPollSelectorProvider();
       
    54                             return provider;
       
    55                         }
       
    56                     });
       
    57         }
       
    58     }
       
    59 
       
    60     public AbstractSelector openSelector() throws IOException {
       
    61         return new RdmaPollSelectorImpl(this);
       
    62     }
       
    63 
       
    64     public SocketChannel openSocketChannel()
       
    65             throws IOException {
       
    66         throw new UnsupportedOperationException();
       
    67     }
       
    68 
       
    69     public SocketChannel openSocketChannel(ProtocolFamily family)
       
    70             throws IOException {
       
    71         return new RdmaSocketChannelImpl(this, family);
       
    72     }
       
    73 
       
    74     public ServerSocketChannel openServerSocketChannel()
       
    75             throws IOException {
       
    76         throw new UnsupportedOperationException();
       
    77     }
       
    78 
       
    79     public ServerSocketChannel openServerSocketChannel(ProtocolFamily family)
       
    80             throws IOException {
       
    81         return new RdmaServerSocketChannelImpl(this, family);
       
    82     }
       
    83 
       
    84     public DatagramChannel openDatagramChannel()
       
    85             throws IOException {
       
    86         throw new UnsupportedOperationException();
       
    87     }
       
    88 
       
    89     public DatagramChannel openDatagramChannel(ProtocolFamily family)
       
    90             throws IOException {
       
    91         throw new UnsupportedOperationException();
       
    92     }
       
    93 
       
    94     public Pipe openPipe() throws IOException {
       
    95         throw new UnsupportedOperationException();
       
    96     }
       
    97 }