From 48a102de5a256774f937003b06c327bae33c9c67 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 12 May 2003 01:53:19 +0000 Subject: [PATCH] Allow scene block resolution to be suspended. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2566 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../miso/client/SceneBlockResolver.java | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/miso/client/SceneBlockResolver.java b/src/java/com/threerings/miso/client/SceneBlockResolver.java index 5467420c7..d855df711 100644 --- a/src/java/com/threerings/miso/client/SceneBlockResolver.java +++ b/src/java/com/threerings/miso/client/SceneBlockResolver.java @@ -1,5 +1,5 @@ // -// $Id: SceneBlockResolver.java,v 1.3 2003/05/02 18:09:56 mdb Exp $ +// $Id: SceneBlockResolver.java,v 1.4 2003/05/12 01:53:19 mdb Exp $ package com.threerings.miso.client; @@ -24,11 +24,47 @@ public class SceneBlockResolver extends LoopingThread _queue.append(block); } + /** + * Temporarily suspends the scene block resolution thread. + */ + public synchronized void suspendResolution () + { + _resolving = false; + } + + /** + * Restores the operation of the scene block resolution thread after a + * previous call to {@link #suspendResolution}. + */ + public synchronized void restoreResolution () + { + _resolving = true; + notify(); + } + + /** + * Returns the number of scene blocks on the resolution queue. + */ + public int queueSize () + { + return _queue.size(); + } + // documentation inherited public void iterate () { final SceneBlock block = (SceneBlock)_queue.get(); + while (!_resolving) { + synchronized (this) { + try { + wait(); + } catch (InterruptedException ie) { + Log.info("Resolver interrupted."); + } + } + } + try { Log.debug("Resolving block " + block + "."); if (block.resolve()) { @@ -51,4 +87,7 @@ public class SceneBlockResolver extends LoopingThread /** The invoker's queue of units to be executed. */ protected Queue _queue = new Queue(); + + /** Indicates whether or not we are resolving or suspended. */ + protected boolean _resolving = true; }