[#2797] Let EventExecutorGroup extend AutoCloseable
Motivation: To make it more easy to shutdown an EventExecutorGroup / EventLoopGroup we should let both of them extend AutoCloseable. Modifications: Let EventExecutorGroup extend AutoCloseable and impement it. Result: Easier shutdown of EventExecutorGroup and EventLoopGroup
This commit is contained in:
parent
0381fa67a8
commit
0b5df22aec
@ -154,4 +154,9 @@ public abstract class AbstractEventExecutor extends AbstractExecutorService impl
|
||||
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
shutdownGracefully().syncUninterruptibly();
|
||||
}
|
||||
}
|
||||
|
@ -114,4 +114,9 @@ public abstract class AbstractEventExecutorGroup implements EventExecutorGroup {
|
||||
public void execute(Runnable command) {
|
||||
next().execute(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
shutdownGracefully().syncUninterruptibly();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* to shut them down in a global fashion.
|
||||
*
|
||||
*/
|
||||
public interface EventExecutorGroup extends ScheduledExecutorService {
|
||||
public interface EventExecutorGroup extends ScheduledExecutorService, AutoCloseable {
|
||||
|
||||
/**
|
||||
* Returns {@code true} if and only if all {@link EventExecutor}s managed by this {@link EventExecutorGroup}
|
||||
|
@ -326,6 +326,11 @@ abstract class PausableChannelEventExecutor implements PausableEventExecutor, Ch
|
||||
unwrap().execute(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
unwrap().close();
|
||||
}
|
||||
|
||||
private static final class ChannelCallableEventExecutor<V> implements CallableEventExecutorAdapter<V> {
|
||||
|
||||
final Channel channel;
|
||||
|
Loading…
Reference in New Issue
Block a user