Exemplo n.º 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);
  }
Exemplo n.º 2
0
  public synchronized boolean addChannel(Channel channel) {
    if (closed) {
      channel.close();
      return false;
    }

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