From c74dd49f67735384e4e78d4b0503121d938e58f4 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sun, 17 Jul 2011 16:32:34 -0500 Subject: [PATCH] Make workaround for adaptive - be faster when bukkit isn't tripping up --- src/main/java/org/dynmap/MapManager.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/dynmap/MapManager.java b/src/main/java/org/dynmap/MapManager.java index 89ea419b..5de07c69 100644 --- a/src/main/java/org/dynmap/MapManager.java +++ b/src/main/java/org/dynmap/MapManager.java @@ -296,8 +296,10 @@ public class MapManager { } private class ProcessChunkLoads implements Runnable { + long last_tick; public void run() { int cnt = max_chunk_loads_per_tick; + long tick = System.currentTimeMillis(); while(cnt > 0) { MapChunkCache c = chunkloads.peek(); @@ -311,8 +313,16 @@ public class MapManager { } } } - if(mapman.scheduler != null) - mapman.scheduler.scheduleSyncDelayedTask(mapman.plug_in, this, 1); + if(mapman.scheduler != null) { + /* Detect if bukkit is being stupid - add delay of 1 tick if we're being overfed */ + if((tick - last_tick) >= 35) { /* If at least 35msec since last run, try immediate */ + mapman.scheduler.scheduleSyncDelayedTask(mapman.plug_in, this); + } + else { + mapman.scheduler.scheduleSyncDelayedTask(mapman.plug_in, this, 1); + } + last_tick = tick; + } } }