public Long getOldestTaskCreatedTime ( ) { Timer . Context ctx = getOldestTaskTimeTimer . time ( ) ; try { long oldest = Long . MAX_VALUE ; /* * I am asking this question first, because if I ask it after I could * miss the oldest time if the oldest is polled and worked on */ Long oldestQueueTime = this . taskQueue . getOldestQueueTime ( ) ; if ( oldestQueueTime != null ) oldest = oldestQueueTime ; //there is a tiny race condition here... but we just want to make our best attempt long inProgressOldestTime = tasksInProgressTracker . getOldestTime ( ) ; if ( inProgressOldestTime < oldest ) oldest = inProgressOldestTime ; return oldest ; } finally { ctx . stop ( ) ; } }
We want to get the best result possible as this value is used to determine what work needs to be recovered .