1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.channel;
17
18 import io.netty.channel.ChannelFlushPromiseNotifier.FlushCheckpoint;
19 import io.netty.util.concurrent.DefaultProgressivePromise;
20 import io.netty.util.concurrent.EventExecutor;
21 import io.netty.util.concurrent.Future;
22 import io.netty.util.concurrent.GenericFutureListener;
23
24
25
26
27
28
29 public class DefaultChannelProgressivePromise
30 extends DefaultProgressivePromise<Void> implements ChannelProgressivePromise, FlushCheckpoint {
31
32 private final Channel channel;
33 private long checkpoint;
34
35
36
37
38
39
40
41 public DefaultChannelProgressivePromise(Channel channel) {
42 this.channel = channel;
43 }
44
45
46
47
48
49
50
51 public DefaultChannelProgressivePromise(Channel channel, EventExecutor executor) {
52 super(executor);
53 this.channel = channel;
54 }
55
56 @Override
57 protected EventExecutor executor() {
58 EventExecutor e = super.executor();
59 if (e == null) {
60 return channel().eventLoop();
61 } else {
62 return e;
63 }
64 }
65
66 @Override
67 public Channel channel() {
68 return channel;
69 }
70
71 @Override
72 public ChannelProgressivePromise setSuccess() {
73 return setSuccess(null);
74 }
75
76 @Override
77 public ChannelProgressivePromise setSuccess(Void result) {
78 super.setSuccess(result);
79 return this;
80 }
81
82 @Override
83 public boolean trySuccess() {
84 return trySuccess(null);
85 }
86
87 @Override
88 public ChannelProgressivePromise setFailure(Throwable cause) {
89 super.setFailure(cause);
90 return this;
91 }
92
93 @Override
94 public ChannelProgressivePromise setProgress(long progress, long total) {
95 super.setProgress(progress, total);
96 return this;
97 }
98
99 @Override
100 public ChannelProgressivePromise addListener(GenericFutureListener<? extends Future<? super Void>> listener) {
101 super.addListener(listener);
102 return this;
103 }
104
105 @Override
106 public ChannelProgressivePromise addListeners(GenericFutureListener<? extends Future<? super Void>>... listeners) {
107 super.addListeners(listeners);
108 return this;
109 }
110
111 @Override
112 public ChannelProgressivePromise removeListener(GenericFutureListener<? extends Future<? super Void>> listener) {
113 super.removeListener(listener);
114 return this;
115 }
116
117 @Override
118 public ChannelProgressivePromise removeListeners(
119 GenericFutureListener<? extends Future<? super Void>>... listeners) {
120 super.removeListeners(listeners);
121 return this;
122 }
123
124 @Override
125 public ChannelProgressivePromise sync() throws InterruptedException {
126 super.sync();
127 return this;
128 }
129
130 @Override
131 public ChannelProgressivePromise syncUninterruptibly() {
132 super.syncUninterruptibly();
133 return this;
134 }
135
136 @Override
137 public ChannelProgressivePromise await() throws InterruptedException {
138 super.await();
139 return this;
140 }
141
142 @Override
143 public ChannelProgressivePromise awaitUninterruptibly() {
144 super.awaitUninterruptibly();
145 return this;
146 }
147
148 @Override
149 public long flushCheckpoint() {
150 return checkpoint;
151 }
152
153 @Override
154 public void flushCheckpoint(long checkpoint) {
155 this.checkpoint = checkpoint;
156 }
157
158 @Override
159 public ChannelProgressivePromise promise() {
160 return this;
161 }
162
163 @Override
164 protected void checkDeadLock() {
165 if (channel().isRegistered()) {
166 super.checkDeadLock();
167 }
168 }
169
170 @Override
171 public ChannelProgressivePromise unvoid() {
172 return this;
173 }
174
175 @Override
176 public boolean isVoid() {
177 return false;
178 }
179 }