Package java.nio.channels.spi

Examples of java.nio.channels.spi.SelectorProvider


    public static SocketChannel attach(int fd) throws Exception {
        Class<?> cls = UnsafeTcp.class.getClassLoader().loadClass("sun.nio.ch.SocketChannelImpl");

        Constructor<?> ctor = cls.getDeclaredConstructor(SelectorProvider.class, FileDescriptor.class, InetSocketAddress.class);

        SelectorProvider provider = SelectorProvider.provider();
        FileDescriptor fileDesc = UnsafeFs.createFileDescriptor( fd );

        ctor.setAccessible(true);
        SocketChannel socketChannel = (SocketChannel) ctor.newInstance(provider, fileDesc, null);
View Full Code Here


            .forName("sun.nio.ch.EPollSelectorProvider");
        if (providerClazz != null) {
          try {
            Method method = providerClazz.getMethod("provider");
            if (method != null) {
              SelectorProvider selectorProvider = (SelectorProvider) method
                  .invoke(null);
              if (selectorProvider != null) {
                result = selectorProvider.openSelector();
              }
            }
          } catch (Exception e) {
            // ignore
          }
View Full Code Here

    /**
     * @tests AbstractSelectableChannel#provider()
     */
    public void test_provider() {
        SelectorProvider provider = testChannel.provider();
        assertSame(SelectorProvider.provider(), provider);
        testChannel = new MockSelectableChannel(null);
        provider = testChannel.provider();
        assertNull(provider);
    }
View Full Code Here

     */
    private synchronized SelectorInfo get(SelectableChannel channel)
        throws IOException {
      SelectorInfo selInfo = null;

      SelectorProvider provider = channel.provider();

      // pick the list : rarely there is more than one provider in use.
      ProviderInfo pList = providerList;
      while (pList != null && pList.provider != provider) {
        pList = pList.next;
      }
      if (pList == null) {
        // LOG.info("Creating new ProviderInfo : " + provider.toString());
        pList = new ProviderInfo();
        pList.provider = provider;
        pList.queue = new LinkedList<SelectorInfo>();
        pList.next = providerList;
        providerList = pList;
      }

      LinkedList<SelectorInfo> queue = pList.queue;

      if (queue.isEmpty()) {
        Selector selector = provider.openSelector();
        selInfo = new SelectorInfo();
        selInfo.selector = selector;
        selInfo.queue = queue;
      } else {
        selInfo = queue.removeLast();
View Full Code Here

  @Override
  public SocketChannel accept() throws IOException {
    try {
      begin();
      SocketUDT socketUDT = serverSocketUDT.accept();
      SelectorProvider provider = provider();
      return new ChannelSocketUDT(provider, socketUDT);
    } finally {
      end(true);
    }
  }
View Full Code Here

  @Override
  public SocketChannel accept() throws IOException {
    try {
      begin();
      SocketUDT socketUDT = serverSocketUDT.accept();
      SelectorProvider provider = provider();
      return new ChannelSocketUDT(provider, socketUDT);
    } finally {
      end(true);
    }
  }
View Full Code Here

            .forName("sun.nio.ch.EPollSelectorProvider");
        if (providerClazz != null) {
          try {
            Method method = providerClazz.getMethod("provider");
            if (method != null) {
              SelectorProvider selectorProvider = (SelectorProvider) method
                  .invoke(null);
              if (selectorProvider != null) {
                result = selectorProvider.openSelector();
              }
            }
          } catch (Exception e) {
            // ignore
          }
View Full Code Here

        return SelectorFactory.openWithRetryFrom(null, provider);
    }

    private void returnToPool(Selector selector) {
        SelectorProvider provider = selector.provider();
        List<Selector> providerPool = pool.get(provider);
        if (providerPool == null) {
            providerPool = new LinkedList<Selector>();
            pool.put(provider, providerPool);
        }
View Full Code Here

  @Override
  public SocketChannel accept() throws IOException {
    try {
      begin();
      SocketUDT socketUDT = serverSocketUDT.accept();
      SelectorProvider provider = provider();
      return new ChannelSocketUDT(provider, socketUDT);
    } finally {
      end(true);
    }
  }
View Full Code Here

        // Now create the channel. If the socket is a streams socket then
        // we see if tthere is a peer (ie: connected). If so, then we
        // create a SocketChannel, otherwise a ServerSocketChannel.
        // If the socket is a datagram socket then create a DatagramChannel

        SelectorProvider provider = SelectorProvider.provider();
        assert provider instanceof sun.nio.ch.SelectorProviderImpl;

        Channel c;
        if (st == SOCK_STREAM) {
            InetAddress ia = peerAddress0(fdVal);
View Full Code Here

TOP

Related Classes of java.nio.channels.spi.SelectorProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.