Fix a Truly Ancient (TM) bug.

The Scene Resolver thread and the dobj/AWT thread both talk to the _blocks map.  And if the resolver tried to get while someone else was doing a put(), that put could decide to resize/rearrange the map.  Which could result in the resolver not finding its block.  Which resulted in annoying missing tile blocks.  So - ConcurrentHashMap it up.

Woo!



git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@894 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Mike Thomas
2010-03-02 18:33:34 +00:00
parent 829f812a8a
commit ac407478d7
2 changed files with 5 additions and 4 deletions
@@ -47,6 +47,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JFrame; import javax.swing.JFrame;
@@ -1532,7 +1533,8 @@ public class MisoScenePanel extends VirtualMediaPanel
protected RethinkOp _rethinkOp; protected RethinkOp _rethinkOp;
/** Contains our scene blocks. See {@link #getBlock} for details. */ /** Contains our scene blocks. See {@link #getBlock} for details. */
protected HashIntMap<SceneBlock> _blocks = new HashIntMap<SceneBlock>(); protected ConcurrentHashMap<Integer, SceneBlock> _blocks =
new ConcurrentHashMap<Integer, SceneBlock>();
/** A count of blocks in the process of being resolved. */ /** A count of blocks in the process of being resolved. */
protected int _pendingBlocks; protected int _pendingBlocks;
@@ -33,7 +33,6 @@ import java.awt.Rectangle;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.samskivert.util.ArrayUtil; import com.samskivert.util.ArrayUtil;
import com.samskivert.util.IntMap;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.threerings.media.tile.NoSuchTileSetException; import com.threerings.media.tile.NoSuchTileSetException;
@@ -513,7 +512,7 @@ public class SceneBlock
* Links this block to its neighbors; informs neighboring blocks of * Links this block to its neighbors; informs neighboring blocks of
* object coverage. * object coverage.
*/ */
protected void update (IntMap<SceneBlock> blocks) protected void update (Map<Integer, SceneBlock> blocks)
{ {
boolean recover = false; boolean recover = false;
@@ -557,7 +556,7 @@ public class SceneBlock
/** /**
* Sets the footprint of this object tile * Sets the footprint of this object tile
*/ */
protected void setCovered (IntMap<SceneBlock> blocks, SceneObject scobj) protected void setCovered (Map<Integer, SceneBlock> blocks, SceneObject scobj)
{ {
int endx = scobj.info.x - scobj.tile.getBaseWidth() + 1; int endx = scobj.info.x - scobj.tile.getBaseWidth() + 1;
int endy = scobj.info.y - scobj.tile.getBaseHeight() + 1; int endy = scobj.info.y - scobj.tile.getBaseHeight() + 1;