private void reapOld(boolean forceEventReap) {
    synchronized (unprocessedEventsLock) {
      if (uncheckedCount > REAP_THRESHOLD) { // only check every X events
        uncheckedCount = 0;
        long now = System.currentTimeMillis();
        if (!forceEventReap && unprocessedTokens.size() > REAP_THRESHOLD) {
          Iterator<Map.Entry<EventID, Long>> it = unprocessedTokens.entrySet().iterator();
          while (it.hasNext()) {
            Map.Entry<EventID, Long> me = it.next();
            long meValue = me.getValue();
            if (meValue <= now) {
              it.remove();
            } else {
              // all done try again
              break;
            }
          }
        }
        if (forceEventReap || unprocessedEvents.size() > REAP_THRESHOLD) {
          Iterator<Map.Entry<EventID, EventWrapper>> it =
              unprocessedEvents.entrySet().iterator();
          while (it.hasNext()) {
            Map.Entry<EventID, EventWrapper> me = it.next();
            EventWrapper ew = me.getValue();
            if (ew.timeout <= now) {
              it.remove();
              ew.event.release();
            } else {
              // all done try again
              break;
            }
          }
        }
      } else {
        uncheckedCount++;
      }
    }
  }
Call to check if a cleanup of tokens needs to be done
geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessor.java