View Javadoc
1   /*
2    * Copyright 2013 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.util.concurrent;
17  
18  /**
19   * Special {@link ProgressiveFuture} which is writable.
20   */
21  public interface ProgressivePromise<V> extends Promise<V>, ProgressiveFuture<V> {
22  
23      /**
24       * Sets the current progress of the operation and notifies the listeners that implement
25       * {@link GenericProgressiveFutureListener}.
26       */
27      ProgressivePromise<V> setProgress(long progress, long total);
28  
29      /**
30       * Tries to set the current progress of the operation and notifies the listeners that implement
31       * {@link GenericProgressiveFutureListener}.  If the operation is already complete or the progress is out of range,
32       * this method does nothing but returning {@code false}.
33       */
34      boolean tryProgress(long progress, long total);
35  
36      @Override
37      ProgressivePromise<V> setSuccess(V result);
38  
39      @Override
40      ProgressivePromise<V> setFailure(Throwable cause);
41  
42      @Override
43      ProgressivePromise<V> addListener(GenericFutureListener<? extends Future<? super V>> listener);
44  
45      @Override
46      ProgressivePromise<V> addListeners(GenericFutureListener<? extends Future<? super V>>... listeners);
47  
48      @Override
49      ProgressivePromise<V> removeListener(GenericFutureListener<? extends Future<? super V>> listener);
50  
51      @Override
52      ProgressivePromise<V> removeListeners(GenericFutureListener<? extends Future<? super V>>... listeners);
53  
54      @Override
55      ProgressivePromise<V> await() throws InterruptedException;
56  
57      @Override
58      ProgressivePromise<V> awaitUninterruptibly();
59  
60      @Override
61      ProgressivePromise<V> sync() throws InterruptedException;
62  
63      @Override
64      ProgressivePromise<V> syncUninterruptibly();
65  }