示例#1
0
 /** Cleans snapshots of entries over 60 seconds old (executed every second) */
 public void cleanSnapshotDeque() {
   long curTime = GameEngine.getTimestamp(); // We need to compare
   // timestamps
   if (curTime - lastCleanedChatlogs > 1000) { // Every second
     lastCleanedChatlogs = curTime;
     lastCleanedChatlogsOutput++;
     if (lastCleanedChatlogsOutput > 60 * 5) {
       Logger.println("----------------------------------------------");
       Logger.println(world.getSnapshots().size() + " items on deque");
     }
     Iterator<Snapshot> i = world.getSnapshots().descendingIterator();
     Snapshot s = null;
     while (i.hasNext()) {
       s = i.next();
       if (curTime - s.getTimestamp() > 60000) {
         i.remove();
         s = null;
       } else {
         s = null;
       }
     }
     i = null;
     if (lastCleanedChatlogsOutput > 60 * 5) {
       Logger.println(world.getSnapshots().size() + " items on deque AFTER CLEANUP");
       Logger.println("----------------------------------------------");
       lastCleanedChatlogsOutput = 0;
     }
   }
 }