private void updateProcessedCounters ( int snapshotFinishedWorkers ) { if ( isInterrupted ( ) ) { wakeUpWorkers ( ) ; return ; } if ( countStartedWorkers_ . get ( ) > snapshotFinishedWorkers ) { /* * We are not the last worker processing the saturation state, so * the current jobs and contexts may not be processed yet. */ return ; } /* * Otherwise we were the last worker processing the saturation state; * take the values for current jobs and contexts and verify that we are * still the last worker (thus the order is important here). */ int snapshotCountJobsSubmitted = countJobsSubmittedUpper_ . get ( ) ; int snapshotCountContextNonSaturated = saturationState_ . getContextMarkNonSaturatedCount ( ) ; int snapshotCountStartedWorkers = countStartedWorkers_ . get ( ) ; if ( snapshotCountStartedWorkers > snapshotFinishedWorkers ) { /* no longer the last worker */ return ; } /* * If we arrive here, #snapshotCountJobsSubmitted and * #snapshotCountContextNonSaturated represents at least the number of * jobs processed and saturated contexts. Furthermore, since we took * them in this order, we know that all contexts for the processed jobs * were created, saturated, and counted. Now, we updated the * corresponding counters for the processed contexts and jobs but in the * reversed order to make sure that for every job considered to be * processed all contexts were already considered to be processed. */ if ( updateIfSmaller ( countContextsSaturatedLower_ , snapshotCountContextNonSaturated ) ) { /* * Sleeping workers can now take new inputs. */ wakeUpWorkers ( ) ; } updateIfSmaller ( countJobsProcessedLower_ , snapshotCountJobsSubmitted ) ; }
Updates the counter for processed contexts and jobs