private List < T > finalizeCurrentBatch ( ) { List < T > finalizedList ; synchronized ( items ) { finalizedList = ImmutableList . copyOf ( items ) ; items . clear ( ) ; /* * To avoid reprocessing being triggered on an empty list. */ cancelTask ( maxTask ) ; cancelTask ( idleTask ) ; } return finalizedList ; }
Returns an immutable copy of the existing items and clear the list .