Xj3D VRML/X3D Code API

org.web3d.vrml.nodes.loader
Class ScriptThreadPool

java.lang.Object
  extended byorg.web3d.vrml.nodes.loader.ScriptThreadPool

public class ScriptThreadPool
extends java.lang.Object

A local singleton that manages all of the threads used to load script content.

The singleton loads a number of threads that must use a common map and queue instance for all users. To organise and queue inputs to this class we must first fetch the instance that is running and then query it for the map and queue. Once you have access to these, you are free to use them directly to add or remove items from the general pool.

The number of threads can be controlled at startup of the application by setting a system property. If the property defines a value less than or equal to zero it is ignored and the default number of threads are loaded - 5.

Properties

The following properties are used by this class

Version:
$Revision: 1.9 $
Author:
Justin Couch

Method Summary
 java.util.Map getProgressMap()
          Get the working map of in-progess loading.
static ScriptThreadPool getScriptThreadPool()
          Fetch the singleton instance of this class.
static java.lang.ThreadGroup getThreadGroup()
          Get the thread group that these objects belong to.
 ContentLoadQueue getWaitingList()
          Get the working queue of items yet to be processed.
protected  void restartThreads()
          Insure all threads are running.
 void setErrorReporter(ErrorReporter reporter)
          Register an error reporter with the engine so that any errors generated by the loading of script code can be reported in a nice, pretty fashion.
static void setThreadGroup(java.lang.ThreadGroup tg)
          Set the global thread group that we want these content handlers to run under.
 void shutdown()
          Force a shutdown of the entire thread pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getScriptThreadPool

public static ScriptThreadPool getScriptThreadPool()
Fetch the singleton instance of this class. If there is not an instance running, one is created.

Returns:
The shared instance of this class

setThreadGroup

public static void setThreadGroup(java.lang.ThreadGroup tg)
                           throws java.lang.IllegalStateException
Set the global thread group that we want these content handlers to run under. This can only be set once and must be before the first instance has been created.

Parameters:
tg - The thread group to use
Throws:
java.lang.IllegalStateException - Too late or it has been set already

getThreadGroup

public static java.lang.ThreadGroup getThreadGroup()
Get the thread group that these objects belong to. If one has not been set yet then this will return null.

Returns:
The ThreadGroup holding these objects

setErrorReporter

public void setErrorReporter(ErrorReporter reporter)
Register an error reporter with the engine so that any errors generated by the loading of script code can be reported in a nice, pretty fashion. Setting a value of null will clear the currently set reporter. If one is already set, the new value replaces the old.

Parameters:
reporter - The instance to use or null

getWaitingList

public ContentLoadQueue getWaitingList()
Get the working queue of items yet to be processed. The queue contains the instances of LoadRequest objects that are to be processed.

Returns:
The working queue of objects

getProgressMap

public java.util.Map getProgressMap()
Get the working map of in-progess loading. The map contains the current external node instance as the key and the loader that is handling it as the value.

Returns:
The working map of items

shutdown

public void shutdown()
Force a shutdown of the entire thread pool. All threads will be forcefully terminated


restartThreads

protected void restartThreads()
Insure all threads are running.


Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium