//
// $Id: SceneBlockResolver.java,v 1.3 2003/05/02 18:09:56 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)
    {
        Log.debug("Queueing block for resolution " + block + ".");
        _queue.append(block);
    }

    // documentation inherited
    public void iterate ()
    {
        final SceneBlock block = (SceneBlock)_queue.get();

        try {
            Log.debug("Resolving block " + block + ".");
            if (block.resolve()) {
                Log.debug("Resolved block " + block + ".");
            }

            // 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();
}

@@ -32,17 +32,17 @@
 ava,v 1.
-3
+4
  2003/05
@@ -46,19 +46,19 @@
 /05/
-02 18:09:56
+12 01:53:19
  mdb
@@ -589,125 +589,964 @@
    /
-/ documentation inherited%0A    public void iterate ()%0A    %7B%0A        final SceneBlock block = (SceneBlock)_queue.get();
+**%0A     * Temporarily suspends the scene block resolution thread.%0A     */%0A    public synchronized void suspendResolution ()%0A    %7B%0A        _resolving = false;%0A    %7D%0A%0A    /**%0A     * Restores the operation of the scene block resolution thread after a%0A     * previous call to %7B@link #suspendResolution%7D.%0A     */%0A    public synchronized void restoreResolution ()%0A    %7B%0A        _resolving = true;%0A        notify();%0A    %7D%0A%0A    /**%0A     * Returns the number of scene blocks on the resolution queue.%0A     */%0A    public int queueSize ()%0A    %7B%0A        return _queue.size();%0A    %7D%0A%0A    // documentation inherited%0A    public void iterate ()%0A    %7B%0A        final SceneBlock block = (SceneBlock)_queue.get();%0A%0A        while (!_resolving) %7B%0A            synchronized (this) %7B%0A                try %7B%0A                    wait();%0A                %7D catch (InterruptedException ie) %7B%0A                    Log.info(%22Resolver interrupted.%22);%0A                %7D%0A            %7D%0A        %7D
 %0A%0A  
@@ -2285,11 +2285,120 @@
 Queue();
+%0A%0A    /** Indicates whether or not we are resolving or suspended. */%0A    protected boolean _resolving = true;
 %0A%7D%0A

Allow scene block resolution to be suspended.