Search in sources :

Example 1 with AsynchronousChannelProvider

use of java.nio.channels.spi.AsynchronousChannelProvider in project j2objc by google.

the class AsynchronousSocketChannelTest method test_group.

public void test_group() throws Exception {
    AsynchronousChannelProvider provider = AsynchronousChannelProvider.provider();
    AsynchronousChannelGroup group = provider.openAsynchronousChannelGroup(2, Executors.defaultThreadFactory());
    AsynchronousSocketChannel asc = AsynchronousSocketChannel.open(group);
    assertEquals(provider, asc.provider());
    asc.close();
}
Also used : AsynchronousChannelProvider(java.nio.channels.spi.AsynchronousChannelProvider) AsynchronousSocketChannel(java.nio.channels.AsynchronousSocketChannel) AsynchronousChannelGroup(java.nio.channels.AsynchronousChannelGroup)

Example 2 with AsynchronousChannelProvider

use of java.nio.channels.spi.AsynchronousChannelProvider in project j2objc by google.

the class AsynchronousServerSocketChannelTest method test_group.

public void test_group() throws Throwable {
    AsynchronousChannelProvider provider = AsynchronousChannelProvider.provider();
    AsynchronousChannelGroup group = provider.openAsynchronousChannelGroup(2, Executors.defaultThreadFactory());
    AsynchronousServerSocketChannel assc = AsynchronousServerSocketChannel.open(group);
    assertNull(assc.getLocalAddress());
    assc.bind(new InetSocketAddress(0));
    assertNotNull(assc.getLocalAddress());
    assertEquals(provider, assc.provider());
    assc.close();
}
Also used : AsynchronousChannelProvider(java.nio.channels.spi.AsynchronousChannelProvider) InetSocketAddress(java.net.InetSocketAddress) AsynchronousChannelGroup(java.nio.channels.AsynchronousChannelGroup) AsynchronousServerSocketChannel(java.nio.channels.AsynchronousServerSocketChannel)

Example 3 with AsynchronousChannelProvider

use of java.nio.channels.spi.AsynchronousChannelProvider in project j2objc by google.

the class AsynchronousChannelProviderTest method test_open_methods.

public void test_open_methods() throws Exception {
    AsynchronousChannelProvider provider = AsynchronousChannelProvider.provider();
    assertNotNull(provider);
    assertSame(AsynchronousChannelProvider.provider(), provider);
    assertNotNull(provider.openAsynchronousChannelGroup(1, new TestThreadFactory()));
    assertNotNull(provider.openAsynchronousChannelGroup(Executors.newSingleThreadExecutor(), 1));
    assertNotNull(provider.openAsynchronousServerSocketChannel(AsynchronousChannelGroup.withFixedThreadPool(1, new TestThreadFactory())));
    assertNotNull(provider.openAsynchronousSocketChannel(AsynchronousChannelGroup.withFixedThreadPool(1, new TestThreadFactory())));
    assertNotNull(provider.openAsynchronousChannelGroup(1, new TestThreadFactory()));
}
Also used : AsynchronousChannelProvider(java.nio.channels.spi.AsynchronousChannelProvider)

Example 4 with AsynchronousChannelProvider

use of java.nio.channels.spi.AsynchronousChannelProvider in project baseio by generallycloud.

the class AioSocketChannelContext method initializeChannelGroup.

private void initializeChannelGroup(int SERVER_CORE_SIZE) throws IOException {
    String threadName = "aio-process(tcp-" + getServerConfiguration().getSERVER_PORT() + ")";
    AsynchronousChannelProvider provider = AsynchronousChannelProvider.provider();
    CachedAioThreadFactory cachedAioThreadFactory = new CachedAioThreadFactory(this, threadName);
    this.asynchronousChannelGroup = provider.openAsynchronousChannelGroup(SERVER_CORE_SIZE, cachedAioThreadFactory);
}
Also used : AsynchronousChannelProvider(java.nio.channels.spi.AsynchronousChannelProvider)

Aggregations

AsynchronousChannelProvider (java.nio.channels.spi.AsynchronousChannelProvider)4 AsynchronousChannelGroup (java.nio.channels.AsynchronousChannelGroup)2 InetSocketAddress (java.net.InetSocketAddress)1 AsynchronousServerSocketChannel (java.nio.channels.AsynchronousServerSocketChannel)1 AsynchronousSocketChannel (java.nio.channels.AsynchronousSocketChannel)1