From 6ab0215ea316517ef9794cfbbdd1f537d19167ec Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 15 Jan 2003 02:36:59 +0000 Subject: [PATCH] Created a prefs repository for the cast stuff; use a runtime adjustment to obtain our cache size. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2151 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/java/com/threerings/cast/CastPrefs.java | 17 +++++++++++++++++ .../com/threerings/cast/CharacterManager.java | 17 ++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 src/java/com/threerings/cast/CastPrefs.java diff --git a/src/java/com/threerings/cast/CastPrefs.java b/src/java/com/threerings/cast/CastPrefs.java new file mode 100644 index 000000000..c19ee57d2 --- /dev/null +++ b/src/java/com/threerings/cast/CastPrefs.java @@ -0,0 +1,17 @@ +// +// $Id: CastPrefs.java,v 1.1 2003/01/15 02:36:59 mdb Exp $ + +package com.threerings.cast; + +import com.samskivert.util.Config; + +/** + * Provides access to runtime configuration parameters for this package + * and its subpackages. + */ +public class CastPrefs +{ + /** Used to load our preferences from a properties file and map them + * to the persistent Java preferences repository. */ + public static Config config = new Config("rsrc/config/cast"); +} diff --git a/src/java/com/threerings/cast/CharacterManager.java b/src/java/com/threerings/cast/CharacterManager.java index f91ffcdc5..8f9bc2196 100644 --- a/src/java/com/threerings/cast/CharacterManager.java +++ b/src/java/com/threerings/cast/CharacterManager.java @@ -1,13 +1,13 @@ // -// $Id: CharacterManager.java,v 1.30 2003/01/13 22:53:04 mdb Exp $ +// $Id: CharacterManager.java,v 1.31 2003/01/15 02:36:59 mdb Exp $ package com.threerings.cast; import java.util.Iterator; import java.util.HashMap; -import com.samskivert.util.ConfigUtil; import com.samskivert.util.LRUHashMap; +import com.samskivert.util.RuntimeAdjust; import com.samskivert.util.StringUtil; import com.samskivert.util.Throttle; import com.samskivert.util.Tuple; @@ -44,8 +44,7 @@ public class CharacterManager } // create our in-memory action cache - int acsize = ConfigUtil.getSystemProperty( - "narya.cast.action_cache_size", DEFAULT_ACTION_CACHE_SIZE); + int acsize = _cacheSize.getValue(); Log.debug("Creating action cache [size=" + acsize + "]."); _frames = new LRUHashMap(acsize); _frames.setTracking(true); // TODO @@ -278,7 +277,11 @@ public class CharacterManager /** Throttle our cache status logging to once every 30 seconds. */ protected Throttle _cacheStatThrottle = new Throttle(1, 30000L); - /** The number of actions to cache before we start clearing them - * out. */ - protected static final int DEFAULT_ACTION_CACHE_SIZE = 30; + /** Register our image cache size with the runtime adjustments + * framework. */ + protected static RuntimeAdjust.IntAdjust _cacheSize = + new RuntimeAdjust.IntAdjust( + "Size (in actions) of the character manager LRU action " + + "cache [requires reboot]", "narya.cast.action_cache_size", + CastPrefs.config, 30); }