io.netty.util.concurrent.ProgressivePromise Java Examples

The following examples show how to use io.netty.util.concurrent.ProgressivePromise. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RequestContextAwareProgressivePromise.java    From armeria with Apache License 2.0 5 votes vote down vote up
@Override
@SafeVarargs
public final ProgressivePromise<T> addListeners(
        GenericFutureListener<? extends Future<? super T>>... listeners) {
    for (GenericFutureListener<? extends Future<? super T>> l : listeners) {
        delegate.addListeners(RequestContextAwareFutureListener.of(context, l));
    }
    return this;
}
 
Example #2
Source File: RequestContextAwareProgressivePromise.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public ProgressivePromise<T> removeListener(
        GenericFutureListener<? extends Future<? super T>> listener) {
    throw new UnsupportedOperationException();
}
 
Example #3
Source File: ProtonHandlerAfterRunTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Override
public <V> ProgressivePromise<V> newProgressivePromise() {
   return null;
}
 
Example #4
Source File: ExecutorNettyAdapter.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Override
public <V> ProgressivePromise<V> newProgressivePromise() {
   return null;
}
 
Example #5
Source File: RequestContextTest.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Test
public void contextAwareEventExecutor() throws Exception {
    when(channel.eventLoop()).thenReturn(eventLoop.get());
    final RequestContext context = createContext();
    final Set<Integer> callbacksCalled = Collections.newSetFromMap(new ConcurrentHashMap<>());
    final EventExecutor executor = context.contextAwareEventLoop();
    final CountDownLatch latch = new CountDownLatch(18);
    executor.execute(() -> checkCallback(1, context, callbacksCalled, latch));
    executor.schedule(() -> checkCallback(2, context, callbacksCalled, latch), 0, TimeUnit.SECONDS);
    executor.schedule(() -> {
        checkCallback(2, context, callbacksCalled, latch);
        return "success";
    }, 0, TimeUnit.SECONDS);
    executor.scheduleAtFixedRate(() -> checkCallback(3, context, callbacksCalled, latch), 0, 1000,
                                 TimeUnit.SECONDS);
    executor.scheduleWithFixedDelay(() -> checkCallback(4, context, callbacksCalled, latch), 0, 1000,
                                    TimeUnit.SECONDS);
    executor.submit(() -> checkCallback(5, context, callbacksCalled, latch));
    executor.submit(() -> checkCallback(6, context, callbacksCalled, latch), "success");
    executor.submit(() -> {
        checkCallback(7, context, callbacksCalled, latch);
        return "success";
    });
    executor.invokeAll(makeTaskList(8, 10, context, callbacksCalled, latch));
    executor.invokeAll(makeTaskList(11, 12, context, callbacksCalled, latch), 10000, TimeUnit.SECONDS);
    executor.invokeAny(makeTaskList(13, 13, context, callbacksCalled, latch));
    executor.invokeAny(makeTaskList(14, 14, context, callbacksCalled, latch), 10000, TimeUnit.SECONDS);
    final Promise<String> promise = executor.newPromise();
    promise.addListener(f -> checkCallback(15, context, callbacksCalled, latch));
    promise.setSuccess("success");
    executor.newSucceededFuture("success")
            .addListener(f -> checkCallback(16, context, callbacksCalled, latch));
    executor.newFailedFuture(new IllegalArgumentException())
            .addListener(f -> checkCallback(17, context, callbacksCalled, latch));
    final ProgressivePromise<String> progressivePromise = executor.newProgressivePromise();
    progressivePromise.addListener(f -> checkCallback(18, context, callbacksCalled, latch));
    progressivePromise.setSuccess("success");
    latch.await();
    eventLoop.get().shutdownGracefully();
    await().untilAsserted(() -> {
        assertThat(callbacksCalled).containsExactlyElementsOf(IntStream.rangeClosed(1, 18)
                                                                       .boxed()::iterator);
    });
}
 
Example #6
Source File: RequestContextAwareProgressivePromise.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public ProgressivePromise<T> awaitUninterruptibly() {
    delegate.awaitUninterruptibly();
    return this;
}
 
Example #7
Source File: RequestContextAwareProgressivePromise.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public ProgressivePromise<T> await() throws InterruptedException {
    delegate.await();
    return this;
}
 
Example #8
Source File: RequestContextAwareProgressivePromise.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public ProgressivePromise<T> syncUninterruptibly() {
    delegate.syncUninterruptibly();
    return this;
}
 
Example #9
Source File: RequestContextAwareProgressivePromise.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public ProgressivePromise<T> sync() throws InterruptedException {
    delegate.sync();
    return this;
}
 
Example #10
Source File: RequestContextAwareProgressivePromise.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
@SafeVarargs
public final ProgressivePromise<T> removeListeners(
        GenericFutureListener<? extends Future<? super T>>... listeners) {
    throw new UnsupportedOperationException();
}
 
Example #11
Source File: AbstractSharedExecutorMicrobenchmark.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Override
public <V> ProgressivePromise<V> newProgressivePromise() {
    return executor.newProgressivePromise();
}
 
Example #12
Source File: RequestContextAwareProgressivePromise.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public ProgressivePromise<T> addListener(
        GenericFutureListener<? extends Future<? super T>> listener) {
    delegate.addListener(RequestContextAwareFutureListener.of(context, listener));
    return this;
}
 
Example #13
Source File: RequestContextAwareProgressivePromise.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public ProgressivePromise<T> setFailure(Throwable cause) {
    delegate.setFailure(cause);
    return this;
}
 
Example #14
Source File: RequestContextAwareProgressivePromise.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public ProgressivePromise<T> setSuccess(T result) {
    delegate.setSuccess(result);
    return this;
}
 
Example #15
Source File: RequestContextAwareProgressivePromise.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public ProgressivePromise<T> setProgress(long progress, long total) {
    delegate.setProgress(progress, total);
    return this;
}
 
Example #16
Source File: RequestContextAwareProgressivePromise.java    From armeria with Apache License 2.0 4 votes vote down vote up
RequestContextAwareProgressivePromise(RequestContext context, ProgressivePromise<T> delegate) {
    this.context = context;
    this.delegate = delegate;
}
 
Example #17
Source File: RequestContextAwareEventLoop.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public <V> ProgressivePromise<V> newProgressivePromise() {
    return new RequestContextAwareProgressivePromise<>(context(), delegate().newProgressivePromise());
}
 
Example #18
Source File: AppendEncodeDecodeTest.java    From pravega with Apache License 2.0 4 votes vote down vote up
@Override
public <V> ProgressivePromise<V> newProgressivePromise() {
    return null;
}