public void timeSlotPruning ( long curTime ) { // if a bucket has not been accessed in a while, and it only has // dead entries then get rid of it TimeSlot slotEntry = this . firstSlot ; TimeSlot nextSlot = null ; int endIndex = 0 ; int i ; while ( slotEntry != null ) { nextSlot = slotEntry . nextEntry ; if ( curTime - slotEntry . mostRecentlyAccessedTime > TIMESLOT_PRUNING_THRESHOLD ) { endIndex = slotEntry . lastEntryIndex ; // entries added last are more likely to be active, so // go from last to first for ( i = endIndex ; i >= 0 ; i -- ) { if ( slotEntry . entries [ i ] . state == TimerWorkItem . ENTRY_ACTIVE ) { break ; } } if ( i < 0 ) { // no entries are active removeSlot ( slotEntry ) ; } } slotEntry = nextSlot ; } }
Remove slots which have no active requests and no new requests have been added in a set amount of time .