PromiseCombiner Class — netty Architecture
Architecture documentation for the PromiseCombiner class in PromiseCombiner.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD c034bf85_ba3b_f7d0_2aee_bede5bf5f89f["PromiseCombiner"] 999b95b1_8ccb_d46a_dff4_73833e391cba["PromiseCombiner.java"] c034bf85_ba3b_f7d0_2aee_bede5bf5f89f -->|defined in| 999b95b1_8ccb_d46a_dff4_73833e391cba 312abb58_0acd_99bc_ee81_bdfb642fbeb6["PromiseCombiner()"] c034bf85_ba3b_f7d0_2aee_bede5bf5f89f -->|method| 312abb58_0acd_99bc_ee81_bdfb642fbeb6 b31bd12e_fb72_c32a_41b3_d8f287bfd9f7["add()"] c034bf85_ba3b_f7d0_2aee_bede5bf5f89f -->|method| b31bd12e_fb72_c32a_41b3_d8f287bfd9f7 224b743d_dde5_9af4_da08_23355e7f754c["addAll()"] c034bf85_ba3b_f7d0_2aee_bede5bf5f89f -->|method| 224b743d_dde5_9af4_da08_23355e7f754c b848fecf_3695_33cb_cafc_ce4f3330b4f6["finish()"] c034bf85_ba3b_f7d0_2aee_bede5bf5f89f -->|method| b848fecf_3695_33cb_cafc_ce4f3330b4f6 61cc60e0_a4a2_7876_29bb_7633ddc4c93a["checkInEventLoop()"] c034bf85_ba3b_f7d0_2aee_bede5bf5f89f -->|method| 61cc60e0_a4a2_7876_29bb_7633ddc4c93a 00240b50_b7c1_0e8b_e97f_d918cdc518a8["tryPromise()"] c034bf85_ba3b_f7d0_2aee_bede5bf5f89f -->|method| 00240b50_b7c1_0e8b_e97f_d918cdc518a8 941f5af8_0b7a_57bc_b747_7c813487185c["checkAddAllowed()"] c034bf85_ba3b_f7d0_2aee_bede5bf5f89f -->|method| 941f5af8_0b7a_57bc_b747_7c813487185c
Relationship Graph
Source Code
common/src/main/java/io/netty/util/concurrent/PromiseCombiner.java lines 35–178
public final class PromiseCombiner {
private int expectedCount;
private int doneCount;
private Promise<Void> aggregatePromise;
private Throwable cause;
private final GenericFutureListener<Future<?>> listener = new GenericFutureListener<Future<?>>() {
@Override
public void operationComplete(final Future<?> future) {
if (executor.inEventLoop()) {
operationComplete0(future);
} else {
executor.execute(new Runnable() {
@Override
public void run() {
operationComplete0(future);
}
});
}
}
private void operationComplete0(Future<?> future) {
assert executor.inEventLoop();
++doneCount;
if (!future.isSuccess() && cause == null) {
cause = future.cause();
}
if (doneCount == expectedCount && aggregatePromise != null) {
tryPromise();
}
}
};
private final EventExecutor executor;
/**
* Deprecated use {@link PromiseCombiner#PromiseCombiner(EventExecutor)}.
*/
@Deprecated
public PromiseCombiner() {
this(ImmediateEventExecutor.INSTANCE);
}
/**
* The {@link EventExecutor} to use for notifications. You must call {@link #add(Future)}, {@link #addAll(Future[])}
* and {@link #finish(Promise)} from within the {@link EventExecutor} thread.
*
* @param executor the {@link EventExecutor} to use for notifications.
*/
public PromiseCombiner(EventExecutor executor) {
this.executor = ObjectUtil.checkNotNull(executor, "executor");
}
/**
* Adds a new promise to be combined. New promises may be added until an aggregate promise is added via the
* {@link PromiseCombiner#finish(Promise)} method.
*
* @param promise the promise to add to this promise combiner
*
* @deprecated Replaced by {@link PromiseCombiner#add(Future)}.
*/
@Deprecated
public void add(Promise promise) {
add((Future) promise);
}
/**
* Adds a new future to be combined. New futures may be added until an aggregate promise is added via the
* {@link PromiseCombiner#finish(Promise)} method.
*
* @param future the future to add to this promise combiner
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public void add(Future future) {
checkAddAllowed();
checkInEventLoop();
++expectedCount;
future.addListener(listener);
}
/**
* Adds new promises to be combined. New promises may be added until an aggregate promise is added via the
Source
Frequently Asked Questions
What is the PromiseCombiner class?
PromiseCombiner is a class in the netty codebase, defined in common/src/main/java/io/netty/util/concurrent/PromiseCombiner.java.
Where is PromiseCombiner defined?
PromiseCombiner is defined in common/src/main/java/io/netty/util/concurrent/PromiseCombiner.java at line 35.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free