Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Cleans snapshots of entries over 60 seconds old (executed every second)
- */
- public void cleanSnapshotDeque() {
- long curTime = System.currentTimeMillis();
- if (curTime - lastCleanedChatlogs > 1000) {
- 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;
- }
- }
- }
Add Comment
Please, Sign In to add comment