Redesigned TaskQueue to have a queue and distributor model so that threads can keep their own queues of work to do without locking to check for more work. Tasks are not executed until TaskQueue_WaitForTaskDone calls TaskQueue_DistributeTasks.
Added a fast path to TaskQueue_DistributeTasks for tasks that are waiting on other tasks to finish first, they are simply dequeued and re-enqueued immediately, and tend to just live on the distributor queue.
TaskQueue thread count is now dynamically adjusted based on tasks being queued per frame, and has a minimum and maximum thread count.
TaskQueue threads now sleep when idle, this may not be ideal, but did substantially lower the cpu usage so that it doesn't make other applications relatively unresponsive like it did before.
Removed taskqueue_task_t->started field and some other unused fields.
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12513
d7cf8633-e32d-0410-b094-
e92efae38249