Add ChannelGroup.deregister()
This commit is contained in:
parent
33c94a98a3
commit
657f16bf2b
@ -21,6 +21,7 @@ import io.netty.buffer.Unpooled;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelStateHandlerAdapter;
|
import io.netty.channel.ChannelStateHandlerAdapter;
|
||||||
|
import io.netty.channel.EventLoop;
|
||||||
import io.netty.channel.FileRegion;
|
import io.netty.channel.FileRegion;
|
||||||
import io.netty.channel.ServerChannel;
|
import io.netty.channel.ServerChannel;
|
||||||
import io.netty.util.CharsetUtil;
|
import io.netty.util.CharsetUtil;
|
||||||
@ -153,4 +154,13 @@ public interface ChannelGroup extends Set<Channel>, Comparable<ChannelGroup> {
|
|||||||
* the operation is done for all channels
|
* the operation is done for all channels
|
||||||
*/
|
*/
|
||||||
ChannelGroupFuture close();
|
ChannelGroupFuture close();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deregister all {@link Channel}s in this group from their {@link EventLoop}.
|
||||||
|
* Please note that this operation is asynchronous as {@link Channel#deregister()} is.
|
||||||
|
*
|
||||||
|
* @return the {@link ChannelGroupFuture} instance that notifies when
|
||||||
|
* the operation is done for all channels
|
||||||
|
*/
|
||||||
|
ChannelGroupFuture deregister();
|
||||||
}
|
}
|
||||||
|
@ -248,6 +248,21 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
|||||||
return new DefaultChannelGroupFuture(this, futures);
|
return new DefaultChannelGroupFuture(this, futures);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChannelGroupFuture deregister() {
|
||||||
|
Map<Integer, ChannelFuture> futures =
|
||||||
|
new LinkedHashMap<Integer, ChannelFuture>(size());
|
||||||
|
|
||||||
|
for (Channel c: serverChannels.values()) {
|
||||||
|
futures.put(c.id(), c.deregister());
|
||||||
|
}
|
||||||
|
for (Channel c: nonServerChannels.values()) {
|
||||||
|
futures.put(c.id(), c.deregister());
|
||||||
|
}
|
||||||
|
|
||||||
|
return new DefaultChannelGroupFuture(this, futures);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return System.identityHashCode(this);
|
return System.identityHashCode(this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user