Use concurrentmap for dirty_worlds
This commit is contained in:
parent
84c3057f04
commit
1b6e030af1
1 changed files with 12 additions and 11 deletions
|
|
@ -342,7 +342,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean stop = false;
|
private boolean stop = false;
|
||||||
private Set<String> dirty_worlds = new HashSet<String>();
|
private ConcurrentHashMap<String, String> dirty_worlds = new ConcurrentHashMap<String, String>();
|
||||||
private boolean dirty_markers = false;
|
private boolean dirty_markers = false;
|
||||||
|
|
||||||
private class DoFileWrites implements Runnable {
|
private class DoFileWrites implements Runnable {
|
||||||
|
|
@ -350,18 +350,19 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||||
if(stop)
|
if(stop)
|
||||||
return;
|
return;
|
||||||
lock.readLock().lock();
|
lock.readLock().lock();
|
||||||
|
Set<String> dirty = new HashSet<String>(dirty_worlds.keySet());
|
||||||
|
dirty_worlds.clear();
|
||||||
try {
|
try {
|
||||||
/* Write markers first - drives JSON updates too */
|
/* Write markers first - drives JSON updates too */
|
||||||
if(dirty_markers) {
|
if (dirty_markers) {
|
||||||
doSaveMarkers();
|
doSaveMarkers();
|
||||||
dirty_markers = false;
|
dirty_markers = false;
|
||||||
}
|
}
|
||||||
/* Process any dirty worlds */
|
/* Process any dirty worlds */
|
||||||
if(!dirty_worlds.isEmpty()) {
|
if (!dirty.isEmpty()) {
|
||||||
for(String world : dirty_worlds) {
|
for(String world : dirty) {
|
||||||
writeMarkersFile(world);
|
writeMarkersFile(world);
|
||||||
}
|
}
|
||||||
dirty_worlds.clear();
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
lock.readLock().unlock();
|
lock.readLock().unlock();
|
||||||
|
|
@ -872,7 +873,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||||
private void freshenMarkerFiles() {
|
private void freshenMarkerFiles() {
|
||||||
if(MapManager.mapman != null) {
|
if(MapManager.mapman != null) {
|
||||||
for(DynmapWorld w : MapManager.mapman.worlds) {
|
for(DynmapWorld w : MapManager.mapman.worlds) {
|
||||||
dirty_worlds.add(w.getName());
|
dirty_worlds.put(w.getName(),"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -931,7 +932,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||||
static void markerUpdated(MarkerImpl marker, MarkerUpdate update) {
|
static void markerUpdated(MarkerImpl marker, MarkerUpdate update) {
|
||||||
/* Freshen marker file for the world for this marker */
|
/* Freshen marker file for the world for this marker */
|
||||||
if(api != null)
|
if(api != null)
|
||||||
api.dirty_worlds.add(marker.getNormalizedWorld());
|
api.dirty_worlds.put(marker.getNormalizedWorld(),"");
|
||||||
/* Enqueue client update */
|
/* Enqueue client update */
|
||||||
if(MapManager.mapman != null)
|
if(MapManager.mapman != null)
|
||||||
MapManager.mapman.pushUpdate(marker.getNormalizedWorld(), new MarkerUpdated(marker, update == MarkerUpdate.DELETED));
|
MapManager.mapman.pushUpdate(marker.getNormalizedWorld(), new MarkerUpdated(marker, update == MarkerUpdate.DELETED));
|
||||||
|
|
@ -944,7 +945,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||||
static void areaMarkerUpdated(AreaMarkerImpl marker, MarkerUpdate update) {
|
static void areaMarkerUpdated(AreaMarkerImpl marker, MarkerUpdate update) {
|
||||||
/* Freshen marker file for the world for this marker */
|
/* Freshen marker file for the world for this marker */
|
||||||
if(api != null)
|
if(api != null)
|
||||||
api.dirty_worlds.add(marker.getNormalizedWorld());
|
api.dirty_worlds.put(marker.getNormalizedWorld(),"");
|
||||||
/* Enqueue client update */
|
/* Enqueue client update */
|
||||||
if(MapManager.mapman != null)
|
if(MapManager.mapman != null)
|
||||||
MapManager.mapman.pushUpdate(marker.getNormalizedWorld(), new AreaMarkerUpdated(marker, update == MarkerUpdate.DELETED));
|
MapManager.mapman.pushUpdate(marker.getNormalizedWorld(), new AreaMarkerUpdated(marker, update == MarkerUpdate.DELETED));
|
||||||
|
|
@ -957,7 +958,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||||
static void polyLineMarkerUpdated(PolyLineMarkerImpl marker, MarkerUpdate update) {
|
static void polyLineMarkerUpdated(PolyLineMarkerImpl marker, MarkerUpdate update) {
|
||||||
/* Freshen marker file for the world for this marker */
|
/* Freshen marker file for the world for this marker */
|
||||||
if(api != null)
|
if(api != null)
|
||||||
api.dirty_worlds.add(marker.getNormalizedWorld());
|
api.dirty_worlds.put(marker.getNormalizedWorld(),"");
|
||||||
/* Enqueue client update */
|
/* Enqueue client update */
|
||||||
if(MapManager.mapman != null)
|
if(MapManager.mapman != null)
|
||||||
MapManager.mapman.pushUpdate(marker.getNormalizedWorld(), new PolyLineMarkerUpdated(marker, update == MarkerUpdate.DELETED));
|
MapManager.mapman.pushUpdate(marker.getNormalizedWorld(), new PolyLineMarkerUpdated(marker, update == MarkerUpdate.DELETED));
|
||||||
|
|
@ -970,7 +971,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||||
static void circleMarkerUpdated(CircleMarkerImpl marker, MarkerUpdate update) {
|
static void circleMarkerUpdated(CircleMarkerImpl marker, MarkerUpdate update) {
|
||||||
/* Freshen marker file for the world for this marker */
|
/* Freshen marker file for the world for this marker */
|
||||||
if(api != null)
|
if(api != null)
|
||||||
api.dirty_worlds.add(marker.getNormalizedWorld());
|
api.dirty_worlds.put(marker.getNormalizedWorld(),"");
|
||||||
/* Enqueue client update */
|
/* Enqueue client update */
|
||||||
if(MapManager.mapman != null)
|
if(MapManager.mapman != null)
|
||||||
MapManager.mapman.pushUpdate(marker.getNormalizedWorld(), new CircleMarkerUpdated(marker, update == MarkerUpdate.DELETED));
|
MapManager.mapman.pushUpdate(marker.getNormalizedWorld(), new CircleMarkerUpdated(marker, update == MarkerUpdate.DELETED));
|
||||||
|
|
@ -3458,7 +3459,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||||
@Override
|
@Override
|
||||||
public void triggered(DynmapWorld t) {
|
public void triggered(DynmapWorld t) {
|
||||||
/* Update markers for now-active world */
|
/* Update markers for now-active world */
|
||||||
dirty_worlds.add(t.getName());
|
dirty_worlds.put(t.getName(),"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove icon */
|
/* Remove icon */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue