@Override public ChannelGroupFuture newCloseFuture(ChannelMatcher matcher) { Map<Channel, ChannelFuture> futures = new LinkedHashMap<Channel, ChannelFuture>(size()); for (Channel c: serverChannels.values()) { if (matcher.matches(c)) { futures.put(c, c.closeFuture()); } } for (Channel c: nonServerChannels.values()) { if (matcher.matches(c)) { futures.put(c, c.closeFuture()); } } return new DefaultChannelGroupFuture(this, futures, executor); }
@Override protected void checkDeadLock() { EventExecutor e = executor(); if (e != null && e != ImmediateEventExecutor.INSTANCE && e.inEventLoop()) { throw new BlockingOperationException(); } }
DefaultChannelGroupFuture(ChannelGroup group, Map<Channel, ChannelFuture> futures, EventExecutor executor) { super(executor); this.group = group; this.futures = Collections.unmodifiableMap(futures); for (ChannelFuture f: this.futures.values()) { f.addListener(childListener); } // Done on arrival? if (this.futures.isEmpty()) { setSuccess0(); } }
@Override public ChannelGroupFuture newCloseFuture(ChannelMatcher matcher) { Map<Channel, ChannelFuture> futures = new LinkedHashMap<Channel, ChannelFuture>(size()); for (Channel c: serverChannels.values()) { if (matcher.matches(c)) { futures.put(c, c.closeFuture()); } } for (Channel c: nonServerChannels.values()) { if (matcher.matches(c)) { futures.put(c, c.closeFuture()); } } return new DefaultChannelGroupFuture(this, futures, executor); }
DefaultChannelGroupFuture(ChannelGroup group, Map<Channel, ChannelFuture> futures, EventExecutor executor) { super(executor); this.group = group; this.futures = Collections.unmodifiableMap(futures); for (ChannelFuture f: this.futures.values()) { f.addListener(childListener); } // Done on arrival? if (this.futures.isEmpty()) { setSuccess0(); } }
@Override protected void checkDeadLock() { EventExecutor e = executor(); if (e != null && e != ImmediateEventExecutor.INSTANCE && e.inEventLoop()) { throw new BlockingOperationException(); } }
@Override public ChannelGroupFuture close(ChannelMatcher matcher) { if (matcher == null) { throw new NullPointerException("matcher"); } Map<Channel, ChannelFuture> futures = new LinkedHashMap<Channel, ChannelFuture>(size()); if (stayClosed) { // It is important to set the closed to true, before closing channels. // Our invariants are: // closed=true happens-before ChannelGroup.close() // ChannelGroup.add() happens-before checking closed==true // // See https://github.com/netty/netty/issues/4020 closed = true; } for (Channel c: serverChannels.values()) { if (matcher.matches(c)) { futures.put(c, c.close()); } } for (Channel c: nonServerChannels.values()) { if (matcher.matches(c)) { futures.put(c, c.close()); } } return new DefaultChannelGroupFuture(this, futures, executor); }
DefaultChannelGroupFuture(ChannelGroup group, Map<Channel, ChannelFuture> futures, EventExecutor executor) { super(executor); this.group = group; this.futures = Collections.unmodifiableMap(futures); for (ChannelFuture f: this.futures.values()) { f.addListener(childListener); } // Done on arrival? if (this.futures.isEmpty()) { setSuccess0(); } }
@Override protected void checkDeadLock() { EventExecutor e = executor(); if (e != null && e != ImmediateEventExecutor.INSTANCE && e.inEventLoop()) { throw new BlockingOperationException(); } }
@Override public ChannelGroupFuture deregister(ChannelMatcher matcher) { if (matcher == null) { throw new NullPointerException("matcher"); } Map<Channel, ChannelFuture> futures = new LinkedHashMap<Channel, ChannelFuture>(size()); for (Channel c: serverChannels.values()) { if (matcher.matches(c)) { futures.put(c, c.deregister()); } } for (Channel c: nonServerChannels.values()) { if (matcher.matches(c)) { futures.put(c, c.deregister()); } } return new DefaultChannelGroupFuture(this, futures, executor); }
/** * Creates a new instance. */ DefaultChannelGroupFuture(ChannelGroup group, Collection<ChannelFuture> futures, EventExecutor executor) { super(executor); if (group == null) { throw new NullPointerException("group"); } if (futures == null) { throw new NullPointerException("futures"); } this.group = group; Map<Channel, ChannelFuture> futureMap = new LinkedHashMap<Channel, ChannelFuture>(); for (ChannelFuture f: futures) { futureMap.put(f.channel(), f); } this.futures = Collections.unmodifiableMap(futureMap); for (ChannelFuture f: this.futures.values()) { f.addListener(childListener); } // Done on arrival? if (this.futures.isEmpty()) { setSuccess0(); } }
@Override protected void checkDeadLock() { EventExecutor e = executor(); if (e != null && e != ImmediateEventExecutor.INSTANCE && e.inEventLoop()) { throw new BlockingOperationException(); } }
@Override public ChannelGroupFuture disconnect(ChannelMatcher matcher) { if (matcher == null) { throw new NullPointerException("matcher"); } Map<Channel, ChannelFuture> futures = new LinkedHashMap<Channel, ChannelFuture>(size()); for (Channel c: serverChannels.values()) { if (matcher.matches(c)) { futures.put(c, c.disconnect()); } } for (Channel c: nonServerChannels.values()) { if (matcher.matches(c)) { futures.put(c, c.disconnect()); } } return new DefaultChannelGroupFuture(this, futures, executor); }
/** * Creates a new instance. */ DefaultChannelGroupFuture(ChannelGroup group, Collection<ChannelFuture> futures, EventExecutor executor) { super(executor); if (group == null) { throw new NullPointerException("group"); } if (futures == null) { throw new NullPointerException("futures"); } this.group = group; Map<Channel, ChannelFuture> futureMap = new LinkedHashMap<Channel, ChannelFuture>(); for (ChannelFuture f: futures) { futureMap.put(f.channel(), f); } this.futures = Collections.unmodifiableMap(futureMap); for (ChannelFuture f: this.futures.values()) { f.addListener(childListener); } // Done on arrival? if (this.futures.isEmpty()) { setSuccess0(); } }
@Override protected void checkDeadLock() { EventExecutor e = executor(); if (e != null && e != ImmediateEventExecutor.INSTANCE && e.inEventLoop()) { throw new BlockingOperationException(); } }
@Override public ChannelGroupFuture writeAndFlush(Object message, ChannelMatcher matcher, boolean voidPromise) { if (message == null) { throw new NullPointerException("message"); } final ChannelGroupFuture future; if (voidPromise) { for (Channel c: nonServerChannels.values()) { if (matcher.matches(c)) { c.writeAndFlush(safeDuplicate(message), c.voidPromise()); } } future = voidFuture; } else { Map<Channel, ChannelFuture> futures = new LinkedHashMap<Channel, ChannelFuture>(size()); for (Channel c: nonServerChannels.values()) { if (matcher.matches(c)) { futures.put(c, c.writeAndFlush(safeDuplicate(message))); } } future = new DefaultChannelGroupFuture(this, futures, executor); } ReferenceCountUtil.release(message); return future; }
/** * Creates a new instance. */ DefaultChannelGroupFuture(ChannelGroup group, Collection<ChannelFuture> futures, EventExecutor executor) { super(executor); if (group == null) { throw new NullPointerException("group"); } if (futures == null) { throw new NullPointerException("futures"); } this.group = group; Map<Channel, ChannelFuture> futureMap = new LinkedHashMap<Channel, ChannelFuture>(); for (ChannelFuture f: futures) { futureMap.put(f.channel(), f); } this.futures = Collections.unmodifiableMap(futureMap); for (ChannelFuture f: this.futures.values()) { f.addListener(childListener); } // Done on arrival? if (this.futures.isEmpty()) { setSuccess0(); } }
@Override protected void checkDeadLock() { EventExecutor e = executor(); if (e != null && e != ImmediateEventExecutor.INSTANCE && e.inEventLoop()) { throw new BlockingOperationException(); } }
@Override public ChannelGroupFuture close(ChannelMatcher matcher) { if (matcher == null) { throw new NullPointerException("matcher"); } Map<Channel, ChannelFuture> futures = new LinkedHashMap<Channel, ChannelFuture>(size()); if (stayClosed) { // It is important to set the closed to true, before closing channels. // Our invariants are: // closed=true happens-before ChannelGroup.close() // ChannelGroup.add() happens-before checking closed==true // // See https://github.com/netty/netty/issues/4020 closed = true; } for (Channel c: serverChannels.values()) { if (matcher.matches(c)) { futures.put(c, c.close()); } } for (Channel c: nonServerChannels.values()) { if (matcher.matches(c)) { futures.put(c, c.close()); } } return new DefaultChannelGroupFuture(this, futures, executor); }
DefaultChannelGroupFuture(ChannelGroup group, Map<Channel, ChannelFuture> futures, EventExecutor executor) { super(executor); this.group = group; this.futures = Collections.unmodifiableMap(futures); for (ChannelFuture f: this.futures.values()) { f.addListener(childListener); } // Done on arrival? if (this.futures.isEmpty()) { setSuccess0(); } }