X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=taskqueue.c;h=e2445d43cb621dad52c831fd71576ad27656478e;hp=06312cda5095370fb524e8c037e7e90bceab5a76;hb=0207a10e1576d5ebe67730b5b98709383613f4df;hpb=4a09bd0381d7448924cc6adf0e8cdbe392c48cf8 diff --git a/taskqueue.c b/taskqueue.c index 06312cda..e2445d43 100644 --- a/taskqueue.c +++ b/taskqueue.c @@ -1,9 +1,9 @@ #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 @@ -80,7 +80,7 @@ static int TaskQueue_ThreadFunc(void *d) unsigned int sleepcounter = 0; for (;;) { - qboolean quit; + qbool quit; while (s->dequeueposition != s->enqueueposition) { taskqueue_task_t *t = s->queue[s->dequeueposition % THREADTASKS]; @@ -114,7 +114,7 @@ void TaskQueue_Enqueue(int numtasks, taskqueue_task_t *tasks) 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++) @@ -136,9 +136,9 @@ void TaskQueue_Yield(taskqueue_task_t *t) 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) @@ -198,7 +198,7 @@ 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); @@ -210,7 +210,7 @@ void TaskQueue_WaitForTaskDone(taskqueue_task_t *t) } } -void TaskQueue_Frame(qboolean shutdown) +void TaskQueue_Frame(qbool shutdown) { int i; unsigned long long int avg; @@ -293,7 +293,7 @@ void TaskQueue_Setup(taskqueue_task_t *t, taskqueue_task_t *preceding, void(*fun 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