From a03ad10f8db81d2766771072b2327ddb25f77940 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 25 Apr 2003 18:22:26 +0000 Subject: [PATCH] Beginnings of support for asynchronous resolution of scene image data. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2461 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../miso/client/SceneBlockResolver.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/java/com/threerings/miso/client/SceneBlockResolver.java diff --git a/src/java/com/threerings/miso/client/SceneBlockResolver.java b/src/java/com/threerings/miso/client/SceneBlockResolver.java new file mode 100644 index 000000000..416d437b5 --- /dev/null +++ b/src/java/com/threerings/miso/client/SceneBlockResolver.java @@ -0,0 +1,52 @@ +// +// $Id: SceneBlockResolver.java,v 1.1 2003/04/25 18:22:26 mdb Exp $ + +package com.threerings.miso.client; + +import java.awt.EventQueue; + +import com.samskivert.util.LoopingThread; +import com.samskivert.util.Queue; + +import com.threerings.miso.Log; + +/** + * A separate thread for resolving miso scene blocks. + */ +public class SceneBlockResolver extends LoopingThread +{ + /** + * Queues up a scene block for resolution. + */ + public void resolveBlock (SceneBlock block) + { + _queue.append(block); + } + + // documentation inherited + public void iterate () + { + final SceneBlock block = (SceneBlock)_queue.get(); + + try { + // resolve the block + Log.info("Resolving block " + block + "."); + block.resolve(); + + // queue it up on the AWT thread to complete its resolution + EventQueue.invokeLater(new Runnable() { + public void run () { + // let the block's panel know that it is resolved + block.wasResolved(); + } + }); + + } catch (Exception e) { + Log.warning("Block failed during resolution " + block + "."); + Log.logStackTrace(e); + } + } + + /** The invoker's queue of units to be executed. */ + protected Queue _queue = new Queue(); +}