类java.nio.channels.spi.AsynchronousChannelProvider源码实例Demo

下面列出了怎么用java.nio.channels.spi.AsynchronousChannelProvider的API类实例代码及写法,或者点击链接到github查看源代码。

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);
}
 
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);
}
 
源代码3 项目: jdk8u-jdk   文件: AsynchronousChannelGroupImpl.java
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);
}
 
源代码4 项目: Bytecoder   文件: AsynchronousChannelGroupImpl.java
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);
}
 
源代码5 项目: jdk8u-jdk   文件: EPollPort.java
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);
}
 
源代码6 项目: dragonwell8_jdk   文件: Iocp.java
Iocp(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);
    this.port =
      createIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, fixedThreadCount());
    this.nextCompletionKey = 1;
}
 
/**
 * 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");
}
 
源代码8 项目: dragonwell8_jdk   文件: KQueuePort.java
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);
}
 
源代码9 项目: dragonwell8_jdk   文件: SolarisEventPort.java
SolarisEventPort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // create event port
    this.port = port_create();
}
 
源代码10 项目: dragonwell8_jdk   文件: EPollPort.java
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);
}
 
源代码11 项目: dragonwell8_jdk   文件: CheckProvider.java
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 + "'");

}
 
源代码12 项目: openjdk-jdk9   文件: KQueuePort.java
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);
}
 
源代码13 项目: jdk8u-jdk   文件: SolarisEventPort.java
SolarisEventPort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // create event port
    this.port = port_create();
}
 
源代码14 项目: jdk8u-jdk   文件: KQueuePort.java
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);
}
 
源代码15 项目: TencentKona-8   文件: SolarisEventPort.java
SolarisEventPort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // create event port
    this.port = port_create();
}
 
源代码16 项目: TencentKona-8   文件: EPollPort.java
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);
}
 
源代码17 项目: jdk8u60   文件: Iocp.java
Iocp(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);
    this.port =
      createIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, fixedThreadCount());
    this.nextCompletionKey = 1;
}
 
/**
 * 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");
}
 
源代码19 项目: jdk8u60   文件: KQueuePort.java
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);
}
 
源代码20 项目: jdk8u60   文件: EPollPort.java
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);
}
 
源代码21 项目: jdk8u60   文件: CheckProvider.java
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 + "'");

}
 
/**
 * 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");
}
 
源代码23 项目: openjdk-jdk9   文件: CheckProvider.java
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 + "'");

}
 
源代码24 项目: openjdk-jdk9   文件: Iocp.java
Iocp(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);
    this.port =
      createIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, fixedThreadCount());
    this.nextCompletionKey = 1;
}
 
源代码25 项目: openjdk-jdk9   文件: EPollPort.java
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);
}
 
源代码26 项目: openjdk-jdk8u   文件: Iocp.java
Iocp(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);
    this.port =
      createIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, fixedThreadCount());
    this.nextCompletionKey = 1;
}
 
/**
 * 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");
}
 
源代码28 项目: openjdk-jdk8u   文件: KQueuePort.java
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);
}
 
源代码29 项目: openjdk-jdk8u   文件: SolarisEventPort.java
SolarisEventPort(AsynchronousChannelProvider provider, ThreadPool pool)
    throws IOException
{
    super(provider, pool);

    // create event port
    this.port = port_create();
}
 
源代码30 项目: openjdk-jdk8u   文件: EPollPort.java
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);
}
 
 类所在包
 同包方法