Guest User

Untitled

a guest
Jun 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. /**
  2. * Cleans snapshots of entries over 60 seconds old (executed every second)
  3. */
  4. public void cleanSnapshotDeque() {
  5. long curTime = System.currentTimeMillis();
  6. if (curTime - lastCleanedChatlogs > 1000) {
  7. lastCleanedChatlogs = curTime;
  8. lastCleanedChatlogsOutput++;
  9. if(lastCleanedChatlogsOutput > 60*5) {
  10. Logger.println("----------------------------------------------");
  11. Logger.println(world.getSnapshots().size() + " items on deque");
  12. }
  13. Iterator<Snapshot> i = world.getSnapshots().descendingIterator();
  14. Snapshot s = null;
  15. while (i.hasNext()) {
  16. s = i.next();
  17. if (curTime - s.getTimestamp() > 60000) {
  18. i.remove();
  19. s = null;
  20. }
  21. else {
  22. s = null;
  23. }
  24. }
  25. i = null;
  26. if(lastCleanedChatlogsOutput > 60*5) {
  27. Logger.println(world.getSnapshots().size() + " items on deque AFTER CLEANUP");
  28. Logger.println("----------------------------------------------");
  29. lastCleanedChatlogsOutput = 0;
  30. }
  31. }
  32. }
Add Comment
Please, Sign In to add comment