Search in sources :

Example 1 with EventLoopTaskQueueFactory

use of io.netty.channel.EventLoopTaskQueueFactory in project netty by netty.

the class NioEventLoopGroup method newChild.

@Override
protected EventLoop newChild(Executor executor, Object... args) throws Exception {
    SelectorProvider selectorProvider = (SelectorProvider) args[0];
    SelectStrategyFactory selectStrategyFactory = (SelectStrategyFactory) args[1];
    RejectedExecutionHandler rejectedExecutionHandler = (RejectedExecutionHandler) args[2];
    EventLoopTaskQueueFactory taskQueueFactory = null;
    EventLoopTaskQueueFactory tailTaskQueueFactory = null;
    int argsLength = args.length;
    if (argsLength > 3) {
        taskQueueFactory = (EventLoopTaskQueueFactory) args[3];
    }
    if (argsLength > 4) {
        tailTaskQueueFactory = (EventLoopTaskQueueFactory) args[4];
    }
    return new NioEventLoop(this, executor, selectorProvider, selectStrategyFactory.newSelectStrategy(), rejectedExecutionHandler, taskQueueFactory, tailTaskQueueFactory);
}
Also used : EventLoopTaskQueueFactory(io.netty.channel.EventLoopTaskQueueFactory) DefaultSelectStrategyFactory(io.netty.channel.DefaultSelectStrategyFactory) SelectStrategyFactory(io.netty.channel.SelectStrategyFactory) SelectorProvider(java.nio.channels.spi.SelectorProvider) RejectedExecutionHandler(io.netty.util.concurrent.RejectedExecutionHandler)

Example 2 with EventLoopTaskQueueFactory

use of io.netty.channel.EventLoopTaskQueueFactory in project netty by netty.

the class KQueueEventLoopGroup method newChild.

@Override
protected EventLoop newChild(Executor executor, Object... args) throws Exception {
    Integer maxEvents = (Integer) args[0];
    SelectStrategyFactory selectStrategyFactory = (SelectStrategyFactory) args[1];
    RejectedExecutionHandler rejectedExecutionHandler = (RejectedExecutionHandler) args[2];
    EventLoopTaskQueueFactory taskQueueFactory = null;
    EventLoopTaskQueueFactory tailTaskQueueFactory = null;
    int argsLength = args.length;
    if (argsLength > 3) {
        taskQueueFactory = (EventLoopTaskQueueFactory) args[3];
    }
    if (argsLength > 4) {
        tailTaskQueueFactory = (EventLoopTaskQueueFactory) args[4];
    }
    return new KQueueEventLoop(this, executor, maxEvents, selectStrategyFactory.newSelectStrategy(), rejectedExecutionHandler, taskQueueFactory, tailTaskQueueFactory);
}
Also used : EventLoopTaskQueueFactory(io.netty.channel.EventLoopTaskQueueFactory) DefaultSelectStrategyFactory(io.netty.channel.DefaultSelectStrategyFactory) SelectStrategyFactory(io.netty.channel.SelectStrategyFactory) RejectedExecutionHandler(io.netty.util.concurrent.RejectedExecutionHandler)

Example 3 with EventLoopTaskQueueFactory

use of io.netty.channel.EventLoopTaskQueueFactory in project netty by netty.

the class NioEventLoopTest method testCustomQueue.

@Test
public void testCustomQueue() {
    final AtomicBoolean called = new AtomicBoolean();
    NioEventLoopGroup group = new NioEventLoopGroup(1, new ThreadPerTaskExecutor(new DefaultThreadFactory(NioEventLoopGroup.class)), DefaultEventExecutorChooserFactory.INSTANCE, SelectorProvider.provider(), DefaultSelectStrategyFactory.INSTANCE, RejectedExecutionHandlers.reject(), new EventLoopTaskQueueFactory() {

        @Override
        public Queue<Runnable> newTaskQueue(int maxCapacity) {
            called.set(true);
            return new LinkedBlockingQueue<Runnable>(maxCapacity);
        }
    });
    final NioEventLoop loop = (NioEventLoop) group.next();
    try {
        loop.submit(new Runnable() {

            @Override
            public void run() {
            // NOOP.
            }
        }).syncUninterruptibly();
        assertTrue(called.get());
    } finally {
        group.shutdownGracefully();
    }
}
Also used : DefaultThreadFactory(io.netty.util.concurrent.DefaultThreadFactory) EventLoopTaskQueueFactory(io.netty.channel.EventLoopTaskQueueFactory) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ThreadPerTaskExecutor(io.netty.util.concurrent.ThreadPerTaskExecutor) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Queue(java.util.Queue) AbstractEventLoopTest(io.netty.channel.AbstractEventLoopTest) Test(org.junit.jupiter.api.Test)

Example 4 with EventLoopTaskQueueFactory

use of io.netty.channel.EventLoopTaskQueueFactory in project netty by netty.

the class EpollEventLoopGroup method newChild.

@Override
protected EventLoop newChild(Executor executor, Object... args) throws Exception {
    Integer maxEvents = (Integer) args[0];
    SelectStrategyFactory selectStrategyFactory = (SelectStrategyFactory) args[1];
    RejectedExecutionHandler rejectedExecutionHandler = (RejectedExecutionHandler) args[2];
    EventLoopTaskQueueFactory taskQueueFactory = null;
    EventLoopTaskQueueFactory tailTaskQueueFactory = null;
    int argsLength = args.length;
    if (argsLength > 3) {
        taskQueueFactory = (EventLoopTaskQueueFactory) args[3];
    }
    if (argsLength > 4) {
        tailTaskQueueFactory = (EventLoopTaskQueueFactory) args[4];
    }
    return new EpollEventLoop(this, executor, maxEvents, selectStrategyFactory.newSelectStrategy(), rejectedExecutionHandler, taskQueueFactory, tailTaskQueueFactory);
}
Also used : EventLoopTaskQueueFactory(io.netty.channel.EventLoopTaskQueueFactory) DefaultSelectStrategyFactory(io.netty.channel.DefaultSelectStrategyFactory) SelectStrategyFactory(io.netty.channel.SelectStrategyFactory) RejectedExecutionHandler(io.netty.util.concurrent.RejectedExecutionHandler)

Aggregations

EventLoopTaskQueueFactory (io.netty.channel.EventLoopTaskQueueFactory)4 DefaultSelectStrategyFactory (io.netty.channel.DefaultSelectStrategyFactory)3 SelectStrategyFactory (io.netty.channel.SelectStrategyFactory)3 RejectedExecutionHandler (io.netty.util.concurrent.RejectedExecutionHandler)3 AbstractEventLoopTest (io.netty.channel.AbstractEventLoopTest)1 DefaultThreadFactory (io.netty.util.concurrent.DefaultThreadFactory)1 ThreadPerTaskExecutor (io.netty.util.concurrent.ThreadPerTaskExecutor)1 SelectorProvider (java.nio.channels.spi.SelectorProvider)1 Queue (java.util.Queue)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Test (org.junit.jupiter.api.Test)1