public void setNested ( ) { // If using fallback or retry, stop the timeout and restart in synchronous mode if ( timeout != null && ( retry . getMaxRetries ( ) != 0 || fallbackPolicy != null ) ) { timeout . runSyncOnNewThread ( Thread . currentThread ( ) ) ; } int retriesRemaining = this . retry . getMaxRetries ( ) - this . retries ; if ( this . retry . getMaxDuration ( ) != null ) { long maxDuration = this . retry . getMaxDuration ( ) . toNanos ( ) ; long now = System . nanoTime ( ) ; long elapsed = now - this . startTime ; long delay = this . retry . getDelay ( ) . toNanos ( ) ; maxDuration = maxDuration - elapsed ; if ( maxDuration <= delay ) { maxDuration = delay + 1 ; retriesRemaining = 0 ; } this . retry . withMaxDuration ( maxDuration , TimeUnit . NANOSECONDS ) ; } this . retry . withMaxRetries ( retriesRemaining ) ; }
As an asynchronous execution moves from the outer part to the nested inner part update the context s policies