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
This commit is contained in:
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user