Add one new constructor with threadFactory only (#9773)
Motivation: In most cases, we want to use MultithreadEventLoopGroup such as NioEventLoopGroup without setting thread numbers but thread name only. So we need to use followed code: NioEventLoopGroup boss = new NioEventLoopGroup(0, new DefaultThreadFactory("boss")); It looks a bit confuse or strange for the number 0 due to we only want to set thread name. So it will be better to add new constructor for this case. Modifications: add new constructor into all event loop groups, for example: public NioEventLoopGroup(ThreadFactory threadFactory) Result: User can only set thread factory without setting the thread number to 0: NioEventLoopGroup boss = new NioEventLoopGroup(new DefaultThreadFactory("boss"));
This commit is contained in:
parent
2f3622ee63
commit
aa2a9931e8
@ -52,6 +52,14 @@ public final class EpollEventLoopGroup extends MultithreadEventLoopGroup {
|
||||
this(nThreads, (ThreadFactory) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance using the default number of threads and the given {@link ThreadFactory}.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public EpollEventLoopGroup(ThreadFactory threadFactory) {
|
||||
this(0, threadFactory, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance using the specified number of threads and the default {@link ThreadFactory}.
|
||||
*/
|
||||
|
@ -49,6 +49,14 @@ public final class KQueueEventLoopGroup extends MultithreadEventLoopGroup {
|
||||
this(nThreads, (ThreadFactory) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance using the default number of threads and the given {@link ThreadFactory}.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public KQueueEventLoopGroup(ThreadFactory threadFactory) {
|
||||
this(0, threadFactory, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance using the specified number of threads and the default {@link ThreadFactory}.
|
||||
*/
|
||||
|
@ -39,6 +39,15 @@ public class DefaultEventLoopGroup extends MultithreadEventLoopGroup {
|
||||
this(nThreads, (ThreadFactory) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance with the default number of threads and the given {@link ThreadFactory}.
|
||||
*
|
||||
* @param threadFactory the {@link ThreadFactory} or {@code null} to use the default
|
||||
*/
|
||||
public DefaultEventLoopGroup(ThreadFactory threadFactory) {
|
||||
this(0, threadFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance
|
||||
*
|
||||
|
@ -39,6 +39,15 @@ public class LocalEventLoopGroup extends DefaultEventLoopGroup {
|
||||
super(nThreads);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance with the default number of threads and the given {@link ThreadFactory}.
|
||||
*
|
||||
* @param threadFactory the {@link ThreadFactory} or {@code null} to use the default
|
||||
*/
|
||||
public LocalEventLoopGroup(ThreadFactory threadFactory) {
|
||||
super(0, threadFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance
|
||||
*
|
||||
|
@ -52,6 +52,14 @@ public class NioEventLoopGroup extends MultithreadEventLoopGroup {
|
||||
this(nThreads, (Executor) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance using the default number of threads, the given {@link ThreadFactory} and the
|
||||
* {@link SelectorProvider} which is returned by {@link SelectorProvider#provider()}.
|
||||
*/
|
||||
public NioEventLoopGroup(ThreadFactory threadFactory) {
|
||||
this(0, threadFactory, SelectorProvider.provider());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance using the specified number of threads, the given {@link ThreadFactory} and the
|
||||
* {@link SelectorProvider} which is returned by {@link SelectorProvider#provider()}.
|
||||
|
Loading…
Reference in New Issue
Block a user