Package com.ardor3d.util
Class GameTaskQueue
java.lang.Object
com.ardor3d.util.GameTaskQueue
GameTaskQueue
is a simple queuing system to enqueue tasks that need to be accomplished in a specific
thread or phase of the application execution (for example, the OpenGL rendering thread.) Upon sending in a task, the
caller gets back a Future object useful for retrieving a return from the Callable that was passed in.- See Also:
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
clear()
Remove all tasks from this queue without executing them.<V> void
Adds the given task to the internal queue to be invoked later.<V> Future
<V> Adds the Callable to the internal queue to invoked and returns a Future that wraps the return.void
enqueueAll
(GameTaskQueue queue) Move the tasks from the given queue to this one.void
execute()
Execute the tasks from this queue.void
Execute the tasks from this queue.long
min time queue is permitted to execute tasks per frameboolean
The state of thisGameTaskQueue
if it will execute all enqueued Callables on an execute invokation.boolean
void
setExecuteMultiple
(boolean executeMultiple) void
setExecutionTime
(int msecs) Sets the minimum amount of time the queue will execute tasks per frame.int
size()
-
Field Details
-
RENDER
- See Also:
-
UPDATE
- See Also:
-
-
Constructor Details
-
GameTaskQueue
public GameTaskQueue()
-
-
Method Details
-
addExecutionExceptionListener
-
removeExecutionExceptionListener
-
isExecuteAll
public boolean isExecuteAll()The state of thisGameTaskQueue
if it will execute all enqueued Callables on an execute invokation.- Returns:
- boolean
-
setExecuteMultiple
public void setExecuteMultiple(boolean executeMultiple) - Parameters:
executeMultiple
- if false, only one task at most is executed per call to execute. If true, we will execute as many tasks as are available, bounded by the max execution time.- See Also:
-
setExecutionTime
public void setExecutionTime(int msecs) Sets the minimum amount of time the queue will execute tasks per frame. If this is set, executeMultiple is automatically set to true and the execute() loop will execute as many tasks as it can before the execution window threshold is passed. Any remaining tasks will be executed in the following frame.- Parameters:
msecs
- the maximum number of milliseconds to start tasks. Note that this does not guarantee the tasks will finish under this time, only start.
-
getExecutionTime
public long getExecutionTime()min time queue is permitted to execute tasks per frame- Returns:
- -1 if executeAll is false, else min time allocated for task execution per frame
-
enqueue
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
- the return type of the callable- Parameters:
callable
- the callable to enqueue- Returns:
- the task
-
enqueue
Adds the given task to the internal queue to be invoked later.- Type Parameters:
V
- the return type of the task- Parameters:
task
- the task
-
execute
public void execute()Execute the tasks from this queue. Note that depending on the queue type, tasks may expect to be run in a certain context (for example, the Render queue expects to be run from the Thread owning a GL context.) -
execute
Execute the tasks from this queue. Note that depending on the queue type, tasks may expect to be run in a certain context (for example, the Render queue expects to be run from the Thread owning a GL context.)- Parameters:
renderer
- the renderer
-
clear
public void clear()Remove all tasks from this queue without executing them. -
enqueueAll
Move the tasks from the given queue to this one.- Parameters:
queue
- the queue containing the tasks to move
-
size
public int size()- Returns:
- count of tasks in queue.
-