com.jme.util
Class GameTaskQueue

java.lang.Object
  extended by com.jme.util.GameTaskQueue

public class GameTaskQueue
extends java.lang.Object

GameTaskQueue is a simple queueing system to enqueue tasks that need to be accomplished in the OpenGL thread and get back a Future object to be able to retrieve a return from the Callable that was passed in.

Author:
Matthew D. Hicks
See Also:
Future, Callable

Field Summary
static java.lang.String RENDER
           
static java.lang.String UPDATE
           
 
Constructor Summary
GameTaskQueue()
           
 
Method Summary
<V> java.util.concurrent.Future<V>
enqueue(java.util.concurrent.Callable<V> callable)
          Adds the Callable to the internal queue to invoked and returns a Future that wraps the return.
 void execute()
          This method should be invoked in the update() or render() method inside the main game to make sure the tasks are invoked in the OpenGL thread.
 boolean isExecuteAll()
          The state of this GameTaskQueue if it will execute all enqueued Callables on an execute invokation.
 void setExecuteAll(boolean executeAll)
          Sets the executeAll boolean value to determine if when execute() is invoked if it should simply execute one Callable, or if it should invoke all.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RENDER

public static final java.lang.String RENDER
See Also:
Constant Field Values

UPDATE

public static final java.lang.String UPDATE
See Also:
Constant Field Values
Constructor Detail

GameTaskQueue

public GameTaskQueue()
Method Detail

isExecuteAll

public boolean isExecuteAll()
The state of this GameTaskQueue if it will execute all enqueued Callables on an execute invokation.

Returns:
boolean

setExecuteAll

public void setExecuteAll(boolean executeAll)
Sets the executeAll boolean value to determine if when execute() is invoked if it should simply execute one Callable, or if it should invoke all. This defaults to false to keep the game moving more smoothly.

Parameters:
executeAll -

enqueue

public <V> java.util.concurrent.Future<V> enqueue(java.util.concurrent.Callable<V> callable)
Adds the Callable to the internal queue to invoked and returns a Future that wraps the return. This is useful for checking the status of the task as well as being able to retrieve the return object from Callable asynchronously.

Type Parameters:
V -
Parameters:
callable -
Returns:

execute

public void execute()
This method should be invoked in the update() or render() method inside the main game to make sure the tasks are invoked in the OpenGL thread.