예제 #1
0
  public synchronized CompletableFuture<Void> closeChannels() {
    List<CompletableFuture<Channel>> futures = new ArrayList<>();
    for (Channel c : getAllChannels()) {
      futures.add(c.close());
    }

    @SuppressWarnings("rawtypes")
    CompletableFuture[] array = futures.toArray(new CompletableFuture[0]);
    closed = true;
    return CompletableFuture.allOf(array);
  }
예제 #2
0
  public synchronized boolean addChannel(Channel channel) {
    if (closed) {
      channel.close();
      return false;
    }

    this.connectedChannels.add(channel);
    return true;
  }