Let ChannelPromiseAggregator take a vararg of ChannelPromises and rename method

This commit is contained in:
Norman Maurer 2013-02-11 07:33:22 +01:00
parent df53d6d7c5
commit a22725d9fa

View File

@ -35,14 +35,23 @@ public final class ChannelPromiseAggregator implements ChannelFutureListener {
this.aggregatePromise = aggregatePromise;
}
public void addFuture(ChannelPromise promise) {
public ChannelPromiseAggregator add(ChannelPromise... promises) {
if (promises == null) {
throw new NullPointerException("promises");
}
synchronized (this) {
if (pendingPromises == null) {
pendingPromises = new HashSet<ChannelPromise>();
}
pendingPromises.add(promise);
for (ChannelPromise p: promises) {
if (p == null) {
continue;
}
pendingPromises.add(p);
p.addListener(this);
}
}
promise.addListener(this);
return this;
}
@Override