@ Override public long determineCurrentGeneration ( final AtomicLong generation , final long tick ) { // If the scan interval was reached, trigger the // run. if ( tick - lastScan >= scanTicks ) { lastScan = tick ; return generation . incrementAndGet ( ) ; } // Otherwise, give the service discovery serviceDiscoveryVisitors a chance // to increment the generation. for ( ServiceDiscoveryTask visitor : visitors ) { visitor . determineGeneration ( generation , tick ) ; } return generation . get ( ) ; }
Trigger the loop every time enough ticks have been accumulated or whenever any of the visitors requests it .