MasDennis/Rajawali — pull request #599 by jwoolston (2013-04-25 21:17:38+00:00)
Title: WIP: Frame Task Queue

## Problem

The addition, removal or replacement of various items in the library such as objects, cameras and textures currently has serious thread safety issues and requires various work arounds by the developer to get them to add safely.

## Solution

I have implemented a task queue which is processed by the OpenGL thread at the start of `onDrawFrame()`, prior to any render calls. The following items are now handled by the queue:

- Animations
- BaseObject3D children
- Cameras
- Lights (WIP)
- Textures (WIP)
- Plugins

All of the following actions are supported:

- Add (By appending or insert at index)
- Add All (By collection of objects, appended)
- Remove (By object or index)
- Remove All (By collection of objects)
- Replace (By object or index)
- Clear all

The related lists are all now private to `RajawaliRenderer` and cannot be accessed by developers. Should a need to see the contents of a list arrive, methods to create a shallow copy, check if an object exists, and get the count are retained where appropriate. Additionally, all methods such as `addChild()` and `removeChild()` have been removed and replaced with the following methods, which apply to all object types:

- `queueAddTask()`
- `queueAddAllTask()`
- `queueRemoveTask()`
- `queueRemoveAllTask()`
- `queueClearTask()`
- `queueReplaceTask()`

A branch of the examples which has been updated to use the new system can be found at: https://github.com/MasDennis/RajawaliExamples/tree/task-queue-update

I am also working on an example which shows more of the features. Currently I would like if people could take a peek and let me know what they think.