src/jdk.net/linux/classes/jdk/internal/net/rdma/RdmaPollSelectorProvider.java
branchrsocket-branch
changeset 57120 64301e5a0da8
parent 57115 512e7cc6ccce
child 57123 919516f93dcf
equal deleted inserted replaced
57117:7f1b415bfede 57120:64301e5a0da8
     1 /*
     1 /*
     2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    31 import java.nio.channels.Pipe;
    31 import java.nio.channels.Pipe;
    32 import java.nio.channels.ServerSocketChannel;
    32 import java.nio.channels.ServerSocketChannel;
    33 import java.nio.channels.SocketChannel;
    33 import java.nio.channels.SocketChannel;
    34 import java.nio.channels.spi.AbstractSelector;
    34 import java.nio.channels.spi.AbstractSelector;
    35 import java.nio.channels.spi.SelectorProvider;
    35 import java.nio.channels.spi.SelectorProvider;
    36 import sun.nio.ch.SelectorProviderImpl;
       
    37 import java.security.AccessController;
    36 import java.security.AccessController;
    38 import java.security.PrivilegedAction;
    37 import java.security.PrivilegedAction;
    39 
    38 
    40 public class RdmaPollSelectorProvider
    39 public class RdmaPollSelectorProvider
    41     extends SelectorProvider
    40     extends SelectorProvider
    42 {
    41 {
    43     private static final Object lock = new Object();
    42     private static final Object lock = new Object();
    44     private static SelectorProvider provider = null;
    43     private static RdmaPollSelectorProvider provider;
    45 
    44 
    46     public static SelectorProvider provider() {
    45     public static RdmaPollSelectorProvider provider() {
    47         synchronized (lock) {
    46         synchronized (lock) {
    48             if (provider != null)
    47             if (provider != null)
    49                 return provider;
    48                 return provider;
    50             return AccessController.doPrivileged(
    49             return AccessController.doPrivileged(
    51                 new PrivilegedAction<>() {
    50                 new PrivilegedAction<>() {
    52                     public SelectorProvider run() {
    51                     public RdmaPollSelectorProvider run() {
    53                             provider = new RdmaPollSelectorProvider();
    52                             provider = new RdmaPollSelectorProvider();
    54                             return provider;
    53                             return provider;
    55                         }
    54                         }
    56                     });
    55                     });
    57         }
    56         }
    58     }
    57     }
    59 
    58 
       
    59     @Override
    60     public AbstractSelector openSelector() throws IOException {
    60     public AbstractSelector openSelector() throws IOException {
    61         return new RdmaPollSelectorImpl(this);
    61         return new RdmaPollSelectorImpl(this);
    62     }
    62     }
    63 
    63 
    64     public SocketChannel openSocketChannel()
    64     @Override
    65             throws IOException {
    65     public SocketChannel openSocketChannel() {
    66         throw new UnsupportedOperationException();
    66         throw new UnsupportedOperationException();
    67     }
    67     }
    68 
    68 
    69     public SocketChannel openSocketChannel(ProtocolFamily family)
    69     public SocketChannel openSocketChannel(ProtocolFamily family)
    70             throws IOException {
    70         throws IOException
       
    71     {
    71         return new RdmaSocketChannelImpl(this, family);
    72         return new RdmaSocketChannelImpl(this, family);
    72     }
    73     }
    73 
    74 
    74     public ServerSocketChannel openServerSocketChannel()
    75     @Override
    75             throws IOException {
    76     public ServerSocketChannel openServerSocketChannel() {
    76         throw new UnsupportedOperationException();
    77         throw new UnsupportedOperationException();
    77     }
    78     }
    78 
    79 
    79     public ServerSocketChannel openServerSocketChannel(ProtocolFamily family)
    80     public ServerSocketChannel openServerSocketChannel(ProtocolFamily family)
    80             throws IOException {
    81         throws IOException
       
    82     {
    81         return new RdmaServerSocketChannelImpl(this, family);
    83         return new RdmaServerSocketChannelImpl(this, family);
    82     }
    84     }
    83 
    85 
    84     public DatagramChannel openDatagramChannel()
    86     @Override
    85             throws IOException {
    87     public DatagramChannel openDatagramChannel() {
    86         throw new UnsupportedOperationException();
    88         throw new UnsupportedOperationException();
    87     }
    89     }
    88 
    90 
    89     public DatagramChannel openDatagramChannel(ProtocolFamily family)
    91     @Override
    90             throws IOException {
    92     public DatagramChannel openDatagramChannel(ProtocolFamily family) {
    91         throw new UnsupportedOperationException();
    93         throw new UnsupportedOperationException();
    92     }
    94     }
    93 
    95 
    94     public Pipe openPipe() throws IOException {
    96     @Override
       
    97     public Pipe openPipe() {
    95         throw new UnsupportedOperationException();
    98         throw new UnsupportedOperationException();
    96     }
    99     }
    97 }
   100 }