#include "quakedef.h"
#include "taskqueue.h"
-cvar_t taskqueue_minthreads = {CVAR_CLIENT | CVAR_SERVER | CVAR_SAVE, "taskqueue_minthreads", "0", "minimum number of threads to keep active for executing tasks"};
-cvar_t taskqueue_maxthreads = {CVAR_CLIENT | CVAR_SERVER | CVAR_SAVE, "taskqueue_maxthreads", "32", "maximum number of threads to start up as needed based on task count"};
-cvar_t taskqueue_tasksperthread = {CVAR_CLIENT | CVAR_SERVER | CVAR_SAVE, "taskqueue_tasksperthread", "4000", "expected amount of work that a single thread can do in a frame - the number of threads being used depends on the average workload in recent frames"};
+cvar_t taskqueue_minthreads = {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "taskqueue_minthreads", "0", "minimum number of threads to keep active for executing tasks"};
+cvar_t taskqueue_maxthreads = {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "taskqueue_maxthreads", "32", "maximum number of threads to start up as needed based on task count"};
+cvar_t taskqueue_tasksperthread = {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "taskqueue_tasksperthread", "4000", "expected amount of work that a single thread can do in a frame - the number of threads being used depends on the average workload in recent frames"};
#define MAXTHREADS 1024
#define RECENTFRAMES 64 // averaging thread activity over this many frames to decide how many threads we need
unsigned int sleepcounter = 0;
for (;;)
{
- qboolean quit;
+ qbool quit;
while (s->dequeueposition != s->enqueueposition)
{
taskqueue_task_t *t = s->queue[s->dequeueposition % THREADTASKS];
unsigned int newsize = (taskqueue_state.queue_size + numtasks) * 2;
if (newsize < 1024)
newsize = 1024;
- taskqueue_state.queue_data = Mem_Realloc(zonemempool, taskqueue_state.queue_data, sizeof(*taskqueue_state.queue_data) * newsize);
+ taskqueue_state.queue_data = (taskqueue_task_t **)Mem_Realloc(zonemempool, taskqueue_state.queue_data, sizeof(*taskqueue_state.queue_data) * newsize);
taskqueue_state.queue_size = newsize;
}
for (i = 0; i < numtasks; i++)
TaskQueue_Enqueue(1, t);
}
-qboolean TaskQueue_IsDone(taskqueue_task_t *t)
+qbool TaskQueue_IsDone(taskqueue_task_t *t)
{
- return !t->done != 0;
+ return !!t->done;
}
static void TaskQueue_DistributeTasks(void)
void TaskQueue_WaitForTaskDone(taskqueue_task_t *t)
{
- qboolean done = false;
+ qbool done = false;
for (;;)
{
Thread_AtomicLock(&taskqueue_state.command_lock);
}
}
-void TaskQueue_Frame(qboolean shutdown)
+void TaskQueue_Frame(qbool shutdown)
{
int i;
unsigned long long int avg;
void TaskQueue_Task_CheckTasksDone(taskqueue_task_t *t)
{
size_t numtasks = t->i[0];
- taskqueue_task_t *tasks = t->p[0];
+ taskqueue_task_t *tasks = (taskqueue_task_t *)t->p[0];
while (numtasks > 0)
{
// check the last task first as it's usually going to be the last to finish, so we do the least work by checking it first