BasicRetryingFuture( Callable<ResponseT> callable, RetryAlgorithm<ResponseT> retryAlgorithm, RetryingContext context) { this.callable = checkNotNull(callable); this.retryAlgorithm = checkNotNull(retryAlgorithm); this.retryingContext = checkNotNull(context); this.attemptSettings = retryAlgorithm.createFirstAttempt(); // A micro crime, letting "this" reference to escape from constructor before initialization is // completed (via internal non-static class CompletionListener). But it is guaranteed to be ok, // since listener is guaranteed to be called only after this future is // completed and this future is guaranteed to be completed only after it is initialized. Also // since "super" is called explicitly here there are no unexpected overrides of addListener here. super.addListener(new CompletionListener(), MoreExecutors.directExecutor()); }
BasicRetryingFuture( Callable<ResponseT> callable, RetryAlgorithm<ResponseT> retryAlgorithm, RetryingContext context) { this.callable = checkNotNull(callable); this.retryAlgorithm = checkNotNull(retryAlgorithm); this.retryingContext = checkNotNull(context); this.attemptSettings = retryAlgorithm.createFirstAttempt(); // A micro crime, letting "this" reference to escape from constructor before initialization is // completed (via internal non-static class CompletionListener). But it is guaranteed to be ok, // since listener is guaranteed to be called only after this future is // completed and this future is guaranteed to be completed only after it is initialized. Also // since "super" is called explicitly here there are no unexpected overrides of addListener here. super.addListener(new CompletionListener(), MoreExecutors.directExecutor()); }