PromiseTask Class — netty Architecture
Architecture documentation for the PromiseTask class in PromiseTask.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f["PromiseTask"] 8b9f7299_bca5_33cf_05d0_d10886c0c9cb["PromiseTask.java"] a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f -->|defined in| 8b9f7299_bca5_33cf_05d0_d10886c0c9cb 651bae0e_cf25_1a5f_b8c4_35fd6db20a66["PromiseTask()"] a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f -->|method| 651bae0e_cf25_1a5f_b8c4_35fd6db20a66 983474bf_db0e_96bc_8978_83d59aa42c37["hashCode()"] a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f -->|method| 983474bf_db0e_96bc_8978_83d59aa42c37 051571d5_3b92_177d_dc55_82059de17312["equals()"] a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f -->|method| 051571d5_3b92_177d_dc55_82059de17312 9e9d18c1_ddb4_4af3_76a2_6a76b1a08cd6["V()"] a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f -->|method| 9e9d18c1_ddb4_4af3_76a2_6a76b1a08cd6 9841426a_d813_e6ab_d8d2_7348fa2bb204["run()"] a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f -->|method| 9841426a_d813_e6ab_d8d2_7348fa2bb204 c78a9f6c_14a9_da95_694a_8af7a8760c38["clearTaskAfterCompletion()"] a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f -->|method| c78a9f6c_14a9_da95_694a_8af7a8760c38 5f717942_7b2b_07c7_e3bd_295800031412["setFailure()"] a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f -->|method| 5f717942_7b2b_07c7_e3bd_295800031412 75360b21_c5df_76f6_fa7b_19e82e4a20db["setFailureInternal()"] a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f -->|method| 75360b21_c5df_76f6_fa7b_19e82e4a20db 490c1f62_d929_e2fc_554c_0d858cf409f9["tryFailure()"] a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f -->|method| 490c1f62_d929_e2fc_554c_0d858cf409f9 967ff89f_6004_d036_6389_7b757ff51850["tryFailureInternal()"] a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f -->|method| 967ff89f_6004_d036_6389_7b757ff51850 7737134d_59b1_0417_17eb_6751e6c84c2a["setSuccess()"] a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f -->|method| 7737134d_59b1_0417_17eb_6751e6c84c2a 450f0470_89cf_4783_a385_794de610e2f8["setSuccessInternal()"] a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f -->|method| 450f0470_89cf_4783_a385_794de610e2f8 4c565e4d_d781_3e12_a06b_580cae4e351b["trySuccess()"] a3a671b9_b63f_8fe8_5aaa_f5dbcafe605f -->|method| 4c565e4d_d781_3e12_a06b_580cae4e351b
Relationship Graph
Source Code
common/src/main/java/io/netty/util/concurrent/PromiseTask.java lines 21–188
class PromiseTask<V> extends DefaultPromise<V> implements RunnableFuture<V> {
private static final class RunnableAdapter<T> implements Callable<T> {
final Runnable task;
final T result;
RunnableAdapter(Runnable task, T result) {
this.task = task;
this.result = result;
}
@Override
public T call() {
task.run();
return result;
}
@Override
public String toString() {
return "Callable(task: " + task + ", result: " + result + ')';
}
}
private static final Runnable COMPLETED = new SentinelRunnable("COMPLETED");
private static final Runnable CANCELLED = new SentinelRunnable("CANCELLED");
private static final Runnable FAILED = new SentinelRunnable("FAILED");
private static class SentinelRunnable implements Runnable {
private final String name;
SentinelRunnable(String name) {
this.name = name;
}
@Override
public void run() { } // no-op
@Override
public String toString() {
return name;
}
}
// Strictly of type Callable<V> or Runnable
private Object task;
PromiseTask(EventExecutor executor, Runnable runnable, V result) {
super(executor);
task = result == null ? runnable : new RunnableAdapter<V>(runnable, result);
}
PromiseTask(EventExecutor executor, Runnable runnable) {
super(executor);
task = runnable;
}
PromiseTask(EventExecutor executor, Callable<V> callable) {
super(executor);
task = callable;
}
@Override
public final int hashCode() {
return System.identityHashCode(this);
}
@Override
public final boolean equals(Object obj) {
return this == obj;
}
@SuppressWarnings("unchecked")
V runTask() throws Throwable {
final Object task = this.task;
if (task instanceof Callable) {
return ((Callable<V>) task).call();
}
((Runnable) task).run();
return null;
}
Source
Frequently Asked Questions
What is the PromiseTask class?
PromiseTask is a class in the netty codebase, defined in common/src/main/java/io/netty/util/concurrent/PromiseTask.java.
Where is PromiseTask defined?
PromiseTask is defined in common/src/main/java/io/netty/util/concurrent/PromiseTask.java at line 21.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free