summaryrefslogtreecommitdiff
path: root/altosuilib/AltosUIMapCache.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-06-13 21:26:33 -0700
committerKeith Packard <keithp@keithp.com>2014-06-13 21:26:33 -0700
commit9a6a3c34293eac6442f766e13ce148f595e891eb (patch)
tree7a9b05e48f8aabc43260b377c6b7b3559cd75fbd /altosuilib/AltosUIMapCache.java
parent92895c87bc3d97bf4990f1feda0bd8b07da4c405 (diff)
altosuilib: Make map-cache per-window instead of global
This consumes more memory, but avoids cache conflicts between windows Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosuilib/AltosUIMapCache.java')
-rw-r--r--altosuilib/AltosUIMapCache.java22
1 files changed, 12 insertions, 10 deletions
diff --git a/altosuilib/AltosUIMapCache.java b/altosuilib/AltosUIMapCache.java
index e849da79..55311d8c 100644
--- a/altosuilib/AltosUIMapCache.java
+++ b/altosuilib/AltosUIMapCache.java
@@ -31,18 +31,19 @@ public class AltosUIMapCache {
static final int bad_request = 3;
static final int forbidden = 4;
- static private Object fetch_lock = new Object();
+ static final int min_cache_size = 9;
+ static final int max_cache_size = 24;
- static final int min_cache_size = 9;
- static final int max_cache_size = 24;
+ private Object fetch_lock = new Object();
+ private Object cache_lock = new Object();
- static int cache_size = min_cache_size;
+ int cache_size = min_cache_size;
- static AltosUIMapImage[] images = new AltosUIMapImage[cache_size];
+ AltosUIMapImage[] images = new AltosUIMapImage[cache_size];
- static Object cache_lock = new Object();
+ long used;
- public static void set_cache_size(int new_size) {
+ public void set_cache_size(int new_size) {
if (new_size < min_cache_size)
new_size = min_cache_size;
if (new_size > max_cache_size)
@@ -64,9 +65,7 @@ public class AltosUIMapCache {
}
}
- static long used;
-
- public static Image get(AltosUIMapTile tile, AltosUIMapStore store, int width, int height) {
+ public Image get(AltosUIMapTile tile, AltosUIMapStore store, int width, int height) {
int oldest = -1;
long age = used;
@@ -109,4 +108,7 @@ public class AltosUIMapCache {
}
}
}
+
+ public AltosUIMapCache() {
+ }
}