Package org.xj3d.core.loading
Class LoaderThreadPool
java.lang.Object
org.xj3d.core.loading.LoaderThreadPool
A local singleton that manages all of the threads used to load 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
org.xj3d.core.loading.threads
The number of concurrent threads to be started to do loading.
- Version:
- $Revision: 1.6 $
- Author:
- Justin Couch
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Force a clearing of the files currently being loaded by the content loaders.static LoaderThreadPool
Fetch the singleton instance of this class.Map
<String[], LoadRequest> Get the working map of in-progress loading.static ThreadGroup
Get the thread group that these objects belong to.Get the working queue of items yet to be processed.void
Ensure all threads are running.void
setErrorReporter
(org.j3d.util.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
Set the global thread group that we want these content handlers to run under.void
shutdown()
Force a shutdown of the entire thread pool.
-
Method Details
-
getLoaderThreadPool
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
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:
IllegalStateException
- Too late or it has been set already
-
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(org.j3d.util.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
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
Get the working map of in-progress loading. The map contains the current external node instance as the key and the LoadRequest that is handling it as the value.- Returns:
- The working map of items
-
clear
public void clear()Force a clearing of the files currently being loaded by the content loaders. Used when a new world is about to be loaded and the existing pending loads need to be terminated. -
shutdown
public void shutdown()Force a shutdown of the entire thread pool. All threads will be forcefully terminated -
restartThreads
public void restartThreads()Ensure all threads are running.
-