Java Code Examples for java.util.concurrent.CompletionStage#thenRunAsync()

The following examples show how to use java.util.concurrent.CompletionStage#thenRunAsync() . 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: CompletedStage.java    From java-async-util with Apache License 2.0 5 votes vote down vote up
@Override
public CompletionStage<Void> runAfterBothAsync(final CompletionStage<?> other,
    final Runnable action) {
  Objects.requireNonNull(action);
  return other.thenRunAsync(
      this.exception == null
          ? action
          : () -> {
            throw CompletedStage.wrapIfNecessary(this.exception);
          });
}
 
Example 2
Source File: CompletedStage.java    From java-async-util with Apache License 2.0 5 votes vote down vote up
@Override
public CompletionStage<Void> runAfterBothAsync(final CompletionStage<?> other,
    final Runnable action,
    final Executor executor) {
  Objects.requireNonNull(action);
  return other.thenRunAsync(
      this.exception == null
          ? action
          : () -> {
            throw CompletedStage.wrapIfNecessary(this.exception);
          },
      executor);
}
 
Example 3
Source File: AbstractCompletionStageTest.java    From completion-stage with Apache License 2.0 5 votes vote down vote up
@Test // just for code coverage. The code is tested by sync version
public void thenRunAsyncDoesNotFail() {
    CompletionStage<String> completionStage1 = createCompletionStage(VALUE);
    finish(completionStage1);

    completionStage1.thenRunAsync(() -> {
    });
}