X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Futil%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Futil%2Fconcurrent%2FAsyncNotifyingListeningExecutorService.java;h=b23982e31057bd8e95169b2bb9d4d581161e5d9e;hb=c24d6e2f39acbb11e22b5676bb7481ed52bec461;hp=d57ded358f4ab7b1013c84ab4edd03119ceb327c;hpb=c55eefb2dcc799601c6ed51409cd5f670fb7fe73;p=yangtools.git diff --git a/common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/AsyncNotifyingListeningExecutorService.java b/common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/AsyncNotifyingListeningExecutorService.java index d57ded358f..b23982e310 100644 --- a/common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/AsyncNotifyingListeningExecutorService.java +++ b/common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/AsyncNotifyingListeningExecutorService.java @@ -18,26 +18,35 @@ import java.util.concurrent.Callable; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; +import javax.annotation.Nonnull; import javax.annotation.Nullable; /** - * An {@link com.google.common.util.concurrent.ListeningExecutorService} implementation that also allows for an {@link Executor} to be - * specified on construction that is used to execute {@link ListenableFuture} callback Runnables, - * registered via {@link com.google.common.util.concurrent.Futures#addCallback} or {@link ListenableFuture#addListener} directly, - * asynchronously when a task that is run on this executor completes. This is useful when you want - * to guarantee listener callback executions are off-loaded onto another thread to avoid blocking - * the thread that completed the task, as a common use case is to pass an executor that runs tasks - * in the same thread as the caller (ie MoreExecutors#sameThreadExecutor}) to + * An {@link com.google.common.util.concurrent.ListeningExecutorService} + * implementation that also allows for an {@link Executor} to be specified on + * construction that is used to execute {@link ListenableFuture} callback + * Runnables, registered via + * {@link com.google.common.util.concurrent.Futures#addCallback} or + * {@link ListenableFuture#addListener} directly, asynchronously when a task + * that is run on this executor completes. This is useful when you want to + * guarantee listener callback executions are off-loaded onto another thread to + * avoid blocking the thread that completed the task, as a common use case is to + * pass an executor that runs tasks in the same thread as the caller (ie + * MoreExecutors#sameThreadExecutor}) to * {@link ListenableFuture#addListener}. + * *

- * Most commonly, this class would be used in lieu of MoreExecutors#listeningDecorator - * when the underlying delegate Executor is single-threaded, in which case, you may not want - * ListenableFuture callbacks to block the single thread. + * Most commonly, this class would be used in lieu of + * MoreExecutors#listeningDecorator when the underlying delegate + * Executor is single-threaded, in which case, you may not want ListenableFuture + * callbacks to block the single thread. + * *

- * Note: the Executor specified on construction does not replace the Executor specified in - * {@link ListenableFuture#addListener}. The latter Executor is still used however, if it is - * detected that the listener Runnable would execute in the thread that completed the task, the - * listener is executed on Executor specified on construction. + * Note: the Executor specified on construction does not replace the Executor + * specified in {@link ListenableFuture#addListener}. The latter Executor is + * still used however, if it is detected that the listener Runnable would + * execute in the thread that completed the task, the listener is executed on + * Executor specified on construction. * * @author Thomas Pantelis * @see AsyncNotifyingListenableFutureTask @@ -86,7 +95,7 @@ public class AsyncNotifyingListeningExecutorService extends AbstractListeningExe } @Override - public boolean awaitTermination( final long timeout, final TimeUnit unit ) throws InterruptedException { + public boolean awaitTermination( final long timeout, @Nonnull final TimeUnit unit ) throws InterruptedException { return delegate.awaitTermination( timeout, unit ); } @@ -105,16 +114,18 @@ public class AsyncNotifyingListeningExecutorService extends AbstractListeningExe delegate.shutdown(); } + @Nonnull @Override public List shutdownNow() { return delegate.shutdownNow(); } @Override - public void execute( final Runnable command ) { + public void execute( @Nonnull final Runnable command ) { delegate.execute( command ); } + @Nonnull @Override public ListenableFuture submit( final Callable task ) { AsyncNotifyingListenableFutureTask futureTask = newFutureTask( task ); @@ -122,6 +133,7 @@ public class AsyncNotifyingListeningExecutorService extends AbstractListeningExe return futureTask; } + @Nonnull @Override public ListenableFuture submit( final Runnable task ) { AsyncNotifyingListenableFutureTask futureTask = newFutureTask( task, null ); @@ -129,6 +141,7 @@ public class AsyncNotifyingListeningExecutorService extends AbstractListeningExe return futureTask; } + @Nonnull @Override public ListenableFuture submit( final Runnable task, final T result ) { AsyncNotifyingListenableFutureTask futureTask = newFutureTask( task, result );