- java.lang.Object
-
- io.netty5.util.concurrent.AbstractEventExecutor
-
- io.netty5.util.concurrent.AbstractScheduledEventExecutor
-
- io.netty5.util.concurrent.SingleThreadEventExecutor
-
- io.netty5.channel.SingleThreadEventLoop
-
- All Implemented Interfaces:
EventLoop,EventLoopGroup,io.netty5.util.concurrent.EventExecutor,io.netty5.util.concurrent.EventExecutorGroup,io.netty5.util.concurrent.FuturePromiseFactory,io.netty5.util.concurrent.OrderedEventExecutor,Iterable<io.netty5.util.concurrent.EventExecutor>,Executor
public class SingleThreadEventLoop extends io.netty5.util.concurrent.SingleThreadEventExecutor implements EventLoop
-
-
Field Summary
Fields Modifier and Type Field Description protected static intDEFAULT_MAX_PENDING_TASKSprotected static intDEFAULT_MAX_TASKS_PER_RUN
-
Constructor Summary
Constructors Constructor Description SingleThreadEventLoop(Executor executor, IoHandler ioHandler)Create a new instanceSingleThreadEventLoop(Executor executor, IoHandler ioHandler, int maxPendingTasks, io.netty5.util.concurrent.RejectedExecutionHandler rejectedHandler)Create a new instanceSingleThreadEventLoop(Executor executor, IoHandler ioHandler, int maxPendingTasks, io.netty5.util.concurrent.RejectedExecutionHandler rejectedHandler, int maxTasksPerRun)Create a new instanceSingleThreadEventLoop(ThreadFactory threadFactory, IoHandler ioHandler)Create a new instanceSingleThreadEventLoop(ThreadFactory threadFactory, IoHandler ioHandler, int maxPendingTasks, io.netty5.util.concurrent.RejectedExecutionHandler rejectedHandler)Create a new instanceSingleThreadEventLoop(ThreadFactory threadFactory, IoHandler ioHandler, int maxPendingTasks, io.netty5.util.concurrent.RejectedExecutionHandler rejectedHandler, int maxTasksPerRun)Create a new instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcleanup()io.netty5.util.concurrent.Future<Void>deregisterForIo(IoHandle handle)booleanisCompatible(Class<? extends IoHandle> handleType)Returnstrueif the given type is compatible with thisEventLoopGroupand so can be registered to the containedEventLoops,falseotherwise.protected Queue<Runnable>newTaskQueue(int maxPendingTasks)io.netty5.util.concurrent.Future<Void>registerForIo(IoHandle handle)protected voidrun()protected intrunIO()Called when IO will be processed for all theChannels on thisSingleThreadEventLoop.protected booleanwakesUpForTask(Runnable task)protected voidwakeup(boolean inEventLoop)-
Methods inherited from class io.netty5.util.concurrent.SingleThreadEventExecutor
addShutdownHook, awaitTermination, confirmShutdown, deadlineNanos, delayNanos, execute, hasTasks, inEventLoop, interruptThread, isShutdown, isShuttingDown, isTerminated, offerTask, pendingTasks, pollTask, reject, removeShutdownHook, removeTask, runAllTasks, shutdownGracefully, takeTask, terminationFuture, threadProperties, updateLastExecutionTime
-
Methods inherited from class io.netty5.util.concurrent.AbstractScheduledEventExecutor
cancelScheduledTasks, getCurrentTimeNanos, hasScheduledTasks, initialNanoTime, nanoTime, newRunnableScheduledFuture, newScheduledTaskFor, nextScheduledTaskNano, pollScheduledTask, pollScheduledTask, schedule, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay
-
Methods inherited from class io.netty5.util.concurrent.AbstractEventExecutor
newSucceededFuture, newTaskFor, newTaskFor, submit, submit, submit
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.util.concurrent.EventExecutor
execute, inEventLoop, inEventLoop, iterator, newFailedFuture, newPromise, newSucceededFuture, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, submit, submit, submit
-
Methods inherited from interface io.netty5.util.concurrent.EventExecutorGroup
awaitTermination, isShutdown, isShuttingDown, isTerminated, shutdownGracefully, shutdownGracefully, terminationFuture
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
SingleThreadEventLoop
public SingleThreadEventLoop(ThreadFactory threadFactory, IoHandler ioHandler)
Create a new instance- Parameters:
threadFactory- theThreadFactorywhich will be used for the usedThreadioHandler- theIoHandlerto use.
-
SingleThreadEventLoop
public SingleThreadEventLoop(Executor executor, IoHandler ioHandler)
Create a new instance
-
SingleThreadEventLoop
public SingleThreadEventLoop(ThreadFactory threadFactory, IoHandler ioHandler, int maxPendingTasks, io.netty5.util.concurrent.RejectedExecutionHandler rejectedHandler)
Create a new instance- Parameters:
threadFactory- theThreadFactorywhich will be used for the usedThreadioHandler- theIoHandlerto use.maxPendingTasks- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler- theRejectedExecutionHandlerto use.
-
SingleThreadEventLoop
public SingleThreadEventLoop(Executor executor, IoHandler ioHandler, int maxPendingTasks, io.netty5.util.concurrent.RejectedExecutionHandler rejectedHandler)
Create a new instance
-
SingleThreadEventLoop
public SingleThreadEventLoop(ThreadFactory threadFactory, IoHandler ioHandler, int maxPendingTasks, io.netty5.util.concurrent.RejectedExecutionHandler rejectedHandler, int maxTasksPerRun)
Create a new instance- Parameters:
threadFactory- theThreadFactorywhich will be used for the usedThreadioHandler- theIoHandlerto use.maxPendingTasks- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler- theRejectedExecutionHandlerto use.maxTasksPerRun- the maximum number of tasks perEventLooprun that will be processed before trying to handle IO again.
-
SingleThreadEventLoop
public SingleThreadEventLoop(Executor executor, IoHandler ioHandler, int maxPendingTasks, io.netty5.util.concurrent.RejectedExecutionHandler rejectedHandler, int maxTasksPerRun)
Create a new instance- Parameters:
executor- theExecutorwhich will be used to run thisEventLoop.ioHandler- theIoHandlerto use.maxPendingTasks- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler- theRejectedExecutionHandlerto use.maxTasksPerRun- the maximum number of tasks perEventLooprun that will be processed before trying to handle IO again.
-
-
Method Detail
-
newTaskQueue
protected Queue<Runnable> newTaskQueue(int maxPendingTasks)
- Overrides:
newTaskQueuein classio.netty5.util.concurrent.SingleThreadEventExecutor
-
wakesUpForTask
protected final boolean wakesUpForTask(Runnable task)
- Overrides:
wakesUpForTaskin classio.netty5.util.concurrent.SingleThreadEventExecutor
-
run
protected void run()
- Overrides:
runin classio.netty5.util.concurrent.SingleThreadEventExecutor
-
runIO
protected int runIO()
Called when IO will be processed for all theChannels on thisSingleThreadEventLoop. This method returns the number ofChannels for which IO was processed. This method must be called from theEventLoopthread.
-
registerForIo
public final io.netty5.util.concurrent.Future<Void> registerForIo(IoHandle handle)
Description copied from interface:EventLoop- Specified by:
registerForIoin interfaceEventLoop- Parameters:
handle- theIoHandleto register.- Returns:
- the
Futurethat is notified once the operations completes.
-
deregisterForIo
public final io.netty5.util.concurrent.Future<Void> deregisterForIo(IoHandle handle)
Description copied from interface:EventLoop- Specified by:
deregisterForIoin interfaceEventLoop- Returns:
- the
Futurethat is notified once the operations completes.
-
wakeup
protected final void wakeup(boolean inEventLoop)
- Overrides:
wakeupin classio.netty5.util.concurrent.SingleThreadEventExecutor
-
cleanup
protected final void cleanup()
- Overrides:
cleanupin classio.netty5.util.concurrent.SingleThreadEventExecutor
-
isCompatible
public boolean isCompatible(Class<? extends IoHandle> handleType)
Description copied from interface:EventLoopGroupReturnstrueif the given type is compatible with thisEventLoopGroupand so can be registered to the containedEventLoops,falseotherwise.- Specified by:
isCompatiblein interfaceEventLoop- Specified by:
isCompatiblein interfaceEventLoopGroup- Parameters:
handleType- the type of theIoHandle.- Returns:
- if compatible of not.
-
-