java.nio.channels.spi.AsynchronousChannelProvider Java Examples

The following examples show how to use java.nio.channels.spi.AsynchronousChannelProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsynchronousChannelGroupImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
AsynchronousChannelGroupImpl(AsynchronousChannelProvider provider,
                             ThreadPool pool)
{
    super(provider);
    this.pool = pool;

    if (pool.isFixedThreadPool()) {
        taskQueue = new ConcurrentLinkedQueue<Runnable>();
    } else {
        taskQueue = null;   // not used
    }

    // use default thread factory as thread should not be visible to
    // application (it doesn't execute completion handlers).
    this.timeoutExecutor = (ScheduledThreadPoolExecutor)
        Executors.newScheduledThreadPool(1, ThreadPool.defaultThreadFactory());
    this.timeoutExecutor.setRemoveOnCancelPolicy(true);
}
 
Example #2
Source File: AsynchronousChannelGroupImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
AsynchronousChannelGroupImpl(AsynchronousChannelProvider provider,
                             ThreadPool pool)
{
    super(provider);
    this.pool = pool;

    if (pool.isFixedThreadPool()) {
        taskQueue = new ConcurrentLinkedQueue<Runnable>();
    } else {
        taskQueue = null;   // not used
    }

    // use default thread factory as thread should not be visible to
    // application (it doesn't execute completion handlers).
    this.timeoutExecutor = (ScheduledThreadPoolExecutor)
        Executors.newScheduledThreadPool(1, ThreadPool.defaultThreadFactory());
    this.timeoutExecutor.setRemoveOnCancelPolicy(true);
}
 
Example #3
Source File: AsynchronousChannelGroupImpl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
AsynchronousChannelGroupImpl(AsynchronousChannelProvider provider,
                             ThreadPool pool)
{
    super(provider);
    this.pool = pool;

    if (pool.isFixedThreadPool()) {
        taskQueue = new ConcurrentLinkedQueue<>();
    } else {
        taskQueue = null;   // not used
    }

    // use default thread factory as thread should not be visible to
    // application (it doesn't execute completion handlers).
    this.timeoutExecutor = (ScheduledThreadPoolExecutor)
        Executors.newScheduledThreadPool(1, ThreadPool.defaultThreadFactory());
    this.timeoutExecutor.setRemoveOnCancelPolicy(true);
}
 
Example #4
Source File: AsynchronousChannelGroupImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
AsynchronousChannelGroupImpl(AsynchronousChannelProvider provider,
                             ThreadPool pool)
{
    super(provider);
    this.pool = pool;

    if (pool.isFixedThreadPool()) {
        taskQueue = new ConcurrentLinkedQueue<Runnable>();
    } else {
        taskQueue = null;   // not used
    }

    // use default thread factory as thread should not be visible to
    // application (it doesn't execute completion handlers).
    this.timeoutExecutor = (ScheduledThreadPoolExecutor)
        Executors.newScheduledThreadPool(1, ThreadPool.defaultThreadFactory());
    this.timeoutExecutor.setRemoveOnCancelPolicy(true);
}
 
Example #5
Source File: CheckProvider.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Class<?> c = AsynchronousChannelProvider.provider().getClass();

    String expected = args[0];
    String actual = c.getName();

    if (!actual.equals(expected))
        throw new RuntimeException("Provider is of type '" + actual +
            "', expected '" + expected + "'");

}
 
Example #6
Source File: Iocp.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
Iocp(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);
    this.port =
      createIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, fixedThreadCount());
    this.nextCompletionKey = 1;
}
 
Example #7
Source File: KQueuePort.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
KQueuePort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // open kqueue
    this.kqfd = kqueue();

    // create socket pair for wakeup mechanism
    int[] sv = new int[2];
    try {
        socketpair(sv);

        // register one end with kqueue
        keventRegister(kqfd, sv[0], EVFILT_READ, EV_ADD);
    } catch (IOException x) {
        close0(kqfd);
        throw x;
    }
    this.sp = sv;

    // allocate the poll array
    this.address = allocatePollArray(MAX_KEVENTS_TO_POLL);

    // create the queue and offer the special event to ensure that the first
    // threads polls
    this.queue = new ArrayBlockingQueue<Event>(MAX_KEVENTS_TO_POLL);
    this.queue.offer(NEED_TO_POLL);
}
 
Example #8
Source File: KQueuePort.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
KQueuePort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // open kqueue
    this.kqfd = kqueue();

    // create socket pair for wakeup mechanism
    int[] sv = new int[2];
    try {
        socketpair(sv);

        // register one end with kqueue
        keventRegister(kqfd, sv[0], EVFILT_READ, EV_ADD);
    } catch (IOException x) {
        close0(kqfd);
        throw x;
    }
    this.sp = sv;

    // allocate the poll array
    this.address = allocatePollArray(MAX_KEVENTS_TO_POLL);

    // create the queue and offer the special event to ensure that the first
    // threads polls
    this.queue = new ArrayBlockingQueue<Event>(MAX_KEVENTS_TO_POLL);
    this.queue.offer(NEED_TO_POLL);
}
 
Example #9
Source File: SolarisEventPort.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
SolarisEventPort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // create event port
    this.port = port_create();
}
 
Example #10
Source File: EPollPort.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
EPollPort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // open epoll
    this.epfd = epollCreate();

    // create socket pair for wakeup mechanism
    int[] sv = new int[2];
    try {
        socketpair(sv);
        // register one end with epoll
        epollCtl(epfd, EPOLL_CTL_ADD, sv[0], Net.POLLIN);
    } catch (IOException x) {
        close0(epfd);
        throw x;
    }
    this.sp = sv;

    // allocate the poll array
    this.address = allocatePollArray(MAX_EPOLL_EVENTS);

    // create the queue and offer the special event to ensure that the first
    // threads polls
    this.queue = new ArrayBlockingQueue<Event>(MAX_EPOLL_EVENTS);
    this.queue.offer(NEED_TO_POLL);
}
 
Example #11
Source File: Iocp.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
Iocp(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);
    this.port =
      createIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, fixedThreadCount());
    this.nextCompletionKey = 1;
}
 
Example #12
Source File: DefaultAsynchronousChannelProvider.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the default AsynchronousChannelProvider.
 */
public static AsynchronousChannelProvider create() {
    String osname = AccessController
        .doPrivileged(new GetPropertyAction("os.name"));
    if (osname.equals("SunOS"))
        return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider");
    if (osname.equals("Linux"))
        return createProvider("sun.nio.ch.LinuxAsynchronousChannelProvider");
    if (osname.contains("OS X"))
        return createProvider("sun.nio.ch.BsdAsynchronousChannelProvider");
    if (osname.equals("AIX"))
        return createProvider("sun.nio.ch.AixAsynchronousChannelProvider");
    throw new InternalError("platform not recognized");
}
 
Example #13
Source File: KQueuePort.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
KQueuePort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // open kqueue
    this.kqfd = kqueue();

    // create socket pair for wakeup mechanism
    int[] sv = new int[2];
    try {
        socketpair(sv);

        // register one end with kqueue
        keventRegister(kqfd, sv[0], EVFILT_READ, EV_ADD);
    } catch (IOException x) {
        close0(kqfd);
        throw x;
    }
    this.sp = sv;

    // allocate the poll array
    this.address = allocatePollArray(MAX_KEVENTS_TO_POLL);

    // create the queue and offer the special event to ensure that the first
    // threads polls
    this.queue = new ArrayBlockingQueue<Event>(MAX_KEVENTS_TO_POLL);
    this.queue.offer(NEED_TO_POLL);
}
 
Example #14
Source File: EPollPort.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
EPollPort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // open epoll
    this.epfd = epollCreate();

    // create socket pair for wakeup mechanism
    int[] sv = new int[2];
    try {
        socketpair(sv);
        // register one end with epoll
        epollCtl(epfd, EPOLL_CTL_ADD, sv[0], Net.POLLIN);
    } catch (IOException x) {
        close0(epfd);
        throw x;
    }
    this.sp = sv;

    // allocate the poll array
    this.address = allocatePollArray(MAX_EPOLL_EVENTS);

    // create the queue and offer the special event to ensure that the first
    // threads polls
    this.queue = new ArrayBlockingQueue<Event>(MAX_EPOLL_EVENTS);
    this.queue.offer(NEED_TO_POLL);
}
 
Example #15
Source File: CheckProvider.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Class<?> c = AsynchronousChannelProvider.provider().getClass();

    String expected = args[0];
    String actual = c.getName();

    if (!actual.equals(expected))
        throw new RuntimeException("Provider is of type '" + actual +
            "', expected '" + expected + "'");

}
 
Example #16
Source File: DefaultAsynchronousChannelProvider.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the default AsynchronousChannelProvider.
 */
public static AsynchronousChannelProvider create() {
    String osname = AccessController
        .doPrivileged(new GetPropertyAction("os.name"));
    if (osname.equals("SunOS"))
        return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider");
    if (osname.equals("Linux"))
        return createProvider("sun.nio.ch.LinuxAsynchronousChannelProvider");
    if (osname.contains("OS X"))
        return createProvider("sun.nio.ch.BsdAsynchronousChannelProvider");
    if (osname.equals("AIX"))
        return createProvider("sun.nio.ch.AixAsynchronousChannelProvider");
    throw new InternalError("platform not recognized");
}
 
Example #17
Source File: EPollPort.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
EPollPort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // open epoll
    this.epfd = epollCreate();

    // create socket pair for wakeup mechanism
    int[] sv = new int[2];
    try {
        socketpair(sv);
        // register one end with epoll
        epollCtl(epfd, EPOLL_CTL_ADD, sv[0], Net.POLLIN);
    } catch (IOException x) {
        close0(epfd);
        throw x;
    }
    this.sp = sv;

    // allocate the poll array
    this.address = allocatePollArray(MAX_EPOLL_EVENTS);

    // create the queue and offer the special event to ensure that the first
    // threads polls
    this.queue = new ArrayBlockingQueue<Event>(MAX_EPOLL_EVENTS);
    this.queue.offer(NEED_TO_POLL);
}
 
Example #18
Source File: Iocp.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
Iocp(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);
    this.port =
      createIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, fixedThreadCount());
    this.nextCompletionKey = 1;
}
 
Example #19
Source File: EPollPort.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
EPollPort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // open epoll
    this.epfd = epollCreate();

    // create socket pair for wakeup mechanism
    int[] sv = new int[2];
    try {
        socketpair(sv);
        // register one end with epoll
        epollCtl(epfd, EPOLL_CTL_ADD, sv[0], Net.POLLIN);
    } catch (IOException x) {
        close0(epfd);
        throw x;
    }
    this.sp = sv;

    // allocate the poll array
    this.address = allocatePollArray(MAX_EPOLL_EVENTS);

    // create the queue and offer the special event to ensure that the first
    // threads polls
    this.queue = new ArrayBlockingQueue<>(MAX_EPOLL_EVENTS);
    this.queue.offer(NEED_TO_POLL);
}
 
Example #20
Source File: Iocp.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
Iocp(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);
    this.port =
      createIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, fixedThreadCount());
    this.nextCompletionKey = 1;
}
 
Example #21
Source File: DefaultAsynchronousChannelProvider.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the default AsynchronousChannelProvider.
 */
public static AsynchronousChannelProvider create() {
    String osname = AccessController
        .doPrivileged(new GetPropertyAction("os.name"));
    if (osname.equals("SunOS"))
        return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider");
    if (osname.equals("Linux"))
        return createProvider("sun.nio.ch.LinuxAsynchronousChannelProvider");
    if (osname.contains("OS X"))
        return createProvider("sun.nio.ch.BsdAsynchronousChannelProvider");
    if (osname.equals("AIX"))
        return createProvider("sun.nio.ch.AixAsynchronousChannelProvider");
    throw new InternalError("platform not recognized");
}
 
Example #22
Source File: KQueuePort.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
KQueuePort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // open kqueue
    this.kqfd = kqueue();

    // create socket pair for wakeup mechanism
    int[] sv = new int[2];
    try {
        socketpair(sv);

        // register one end with kqueue
        keventRegister(kqfd, sv[0], EVFILT_READ, EV_ADD);
    } catch (IOException x) {
        close0(kqfd);
        throw x;
    }
    this.sp = sv;

    // allocate the poll array
    this.address = allocatePollArray(MAX_KEVENTS_TO_POLL);

    // create the queue and offer the special event to ensure that the first
    // threads polls
    this.queue = new ArrayBlockingQueue<Event>(MAX_KEVENTS_TO_POLL);
    this.queue.offer(NEED_TO_POLL);
}
 
Example #23
Source File: SolarisEventPort.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
SolarisEventPort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // create event port
    this.port = port_create();
}
 
Example #24
Source File: EPollPort.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
EPollPort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // open epoll
    this.epfd = epollCreate();

    // create socket pair for wakeup mechanism
    int[] sv = new int[2];
    try {
        socketpair(sv);
        // register one end with epoll
        epollCtl(epfd, EPOLL_CTL_ADD, sv[0], Net.POLLIN);
    } catch (IOException x) {
        close0(epfd);
        throw x;
    }
    this.sp = sv;

    // allocate the poll array
    this.address = allocatePollArray(MAX_EPOLL_EVENTS);

    // create the queue and offer the special event to ensure that the first
    // threads polls
    this.queue = new ArrayBlockingQueue<Event>(MAX_EPOLL_EVENTS);
    this.queue.offer(NEED_TO_POLL);
}
 
Example #25
Source File: CheckProvider.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Class<?> c = AsynchronousChannelProvider.provider().getClass();

    String expected = args[0];
    String actual = c.getName();

    if (!actual.equals(expected))
        throw new RuntimeException("Provider is of type '" + actual +
            "', expected '" + expected + "'");

}
 
Example #26
Source File: SolarisEventPort.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
SolarisEventPort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // create event port
    this.port = port_create();
}
 
Example #27
Source File: DefaultAsynchronousChannelProvider.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the default AsynchronousChannelProvider.
 */
public static AsynchronousChannelProvider create() {
    String osname = AccessController
        .doPrivileged(new GetPropertyAction("os.name"));
    if (osname.equals("SunOS"))
        return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider");
    if (osname.equals("Linux"))
        return createProvider("sun.nio.ch.LinuxAsynchronousChannelProvider");
    if (osname.contains("OS X"))
        return createProvider("sun.nio.ch.BsdAsynchronousChannelProvider");
    if (osname.equals("AIX"))
        return createProvider("sun.nio.ch.AixAsynchronousChannelProvider");
    throw new InternalError("platform not recognized");
}
 
Example #28
Source File: KQueuePort.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
KQueuePort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // open kqueue
    this.kqfd = kqueue();

    // create socket pair for wakeup mechanism
    int[] sv = new int[2];
    try {
        socketpair(sv);

        // register one end with kqueue
        keventRegister(kqfd, sv[0], EVFILT_READ, EV_ADD);
    } catch (IOException x) {
        close0(kqfd);
        throw x;
    }
    this.sp = sv;

    // allocate the poll array
    this.address = allocatePollArray(MAX_KEVENTS_TO_POLL);

    // create the queue and offer the special event to ensure that the first
    // threads polls
    this.queue = new ArrayBlockingQueue<Event>(MAX_KEVENTS_TO_POLL);
    this.queue.offer(NEED_TO_POLL);
}
 
Example #29
Source File: SolarisEventPort.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
SolarisEventPort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // create event port
    this.port = port_create();
}
 
Example #30
Source File: EPollPort.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
EPollPort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // open epoll
    this.epfd = epollCreate();

    // create socket pair for wakeup mechanism
    int[] sv = new int[2];
    try {
        socketpair(sv);
        // register one end with epoll
        epollCtl(epfd, EPOLL_CTL_ADD, sv[0], Net.POLLIN);
    } catch (IOException x) {
        close0(epfd);
        throw x;
    }
    this.sp = sv;

    // allocate the poll array
    this.address = allocatePollArray(MAX_EPOLL_EVENTS);

    // create the queue and offer the special event to ensure that the first
    // threads polls
    this.queue = new ArrayBlockingQueue<Event>(MAX_EPOLL_EVENTS);
    this.queue.offer(NEED_TO_POLL);
}