[#1369] Move ImmediateEventExecutor to common and let it access via a static
* Also fix a bug there to return a correct implementation of ProgressivPRomi ImmediateEventExecutor
This commit is contained in:
parent
a8830aee42
commit
abb4e20d0b
@ -15,15 +15,17 @@
|
||||
*/
|
||||
package io.netty.util.concurrent;
|
||||
|
||||
import io.netty.util.concurrent.AbstractEventExecutor;
|
||||
import io.netty.util.concurrent.DefaultPromise;
|
||||
import io.netty.util.concurrent.EventExecutor;
|
||||
import io.netty.util.concurrent.EventExecutorGroup;
|
||||
import io.netty.util.concurrent.Promise;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
final class ImmediateEventExecutor extends AbstractEventExecutor {
|
||||
/**
|
||||
* {@link AbstractEventExecutor} which execute tasks in the callers thread.
|
||||
*/
|
||||
public final class ImmediateEventExecutor extends AbstractEventExecutor {
|
||||
public static final ImmediateEventExecutor INSTANCE = new ImmediateEventExecutor();
|
||||
|
||||
private ImmediateEventExecutor() {
|
||||
// use static instance
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventExecutorGroup parent() {
|
||||
@ -80,6 +82,11 @@ final class ImmediateEventExecutor extends AbstractEventExecutor {
|
||||
return new ImmediatePromise<V>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> ProgressivePromise<V> newProgressivePromise() {
|
||||
return new ImmediateProgressivePromise<V>(this);
|
||||
}
|
||||
|
||||
static class ImmediatePromise<V> extends DefaultPromise<V> {
|
||||
ImmediatePromise(EventExecutor executor) {
|
||||
super(executor);
|
||||
@ -90,4 +97,15 @@ final class ImmediateEventExecutor extends AbstractEventExecutor {
|
||||
// No check
|
||||
}
|
||||
}
|
||||
|
||||
static class ImmediateProgressivePromise<V> extends DefaultProgressivePromise<V> {
|
||||
ImmediateProgressivePromise(EventExecutor executor) {
|
||||
super(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkDeadLock() {
|
||||
// No check
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,9 @@ public final class ImmediateExecutor implements Executor {
|
||||
|
||||
@Override
|
||||
public void execute(Runnable command) {
|
||||
if (command == null) {
|
||||
throw new NullPointerException("command");
|
||||
}
|
||||
command.run();
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.FileRegion;
|
||||
import io.netty.channel.ServerChannel;
|
||||
import io.netty.util.concurrent.EventExecutor;
|
||||
import io.netty.util.concurrent.ImmediateEventExecutor;
|
||||
import io.netty.util.internal.PlatformDependent;
|
||||
|
||||
import java.util.AbstractSet;
|
||||
@ -39,7 +40,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
public class DefaultChannelGroup extends AbstractSet<Channel> implements ChannelGroup {
|
||||
|
||||
private static final AtomicInteger nextId = new AtomicInteger();
|
||||
private static final ImmediateEventExecutor DEFAULT_EXECUTOR = new ImmediateEventExecutor();
|
||||
private final String name;
|
||||
private final EventExecutor executor;
|
||||
private final ConcurrentMap<Integer, Channel> serverChannels = PlatformDependent.newConcurrentHashMap();
|
||||
@ -72,7 +72,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
||||
* is done against group names.
|
||||
*/
|
||||
public DefaultChannelGroup(String name) {
|
||||
this(name, DEFAULT_EXECUTOR);
|
||||
this(name, ImmediateEventExecutor.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,6 +23,7 @@ import io.netty.util.concurrent.DefaultPromise;
|
||||
import io.netty.util.concurrent.EventExecutor;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
import io.netty.util.concurrent.ImmediateEventExecutor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
Loading…
Reference in New Issue
Block a user