UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
threads.cpp File Reference
#include "bsp.h"
#include "../../shared/thread.h"

Go to the source code of this file.

Macros

#define MAX_THREADS   8
 

Functions

static int GetThreadWork (void)
 Return an iteration of work, updating progress when appropriate. More...
 
static int ThreadWork (void *p)
 Shared work entry point by all threads. Retrieve and perform chunks of work iteratively until work is finished. More...
 
static void ThreadInit (void)
 
static void ThreadRelease (void)
 
void ThreadLock (void)
 Lock the shared data by the calling thread. More...
 
void ThreadUnlock (void)
 Release the lock on the shared data. More...
 
static void RunThreads (void)
 
void RunThreadsOn (void(*func)(unsigned int), int unsigned workcount, bool progress, const char *id)
 Entry point for all thread work requests. More...
 
void RunSingleThreadOn (void(*func)(unsigned int), int unsigned workcount, bool progress, const char *id)
 Entry point for all thread work requests. More...
 

Variables

threadstate_t threadstate
 
static void(* WorkFunction )(unsigned int)
 Generic function pointer to actual work to be done. More...
 
static SDL_mutex * lock = nullptr
 

Macro Definition Documentation

#define MAX_THREADS   8

Definition at line 30 of file threads.cpp.

Referenced by RunThreads(), and RunThreadsOn().

Function Documentation

static int GetThreadWork ( void  )
static

Return an iteration of work, updating progress when appropriate.

Definition at line 37 of file threads.cpp.

References f, ThreadLock(), threadstate, and ThreadUnlock().

Referenced by ThreadWork().

void RunSingleThreadOn ( void(*)(unsigned int func,
int unsigned  workcount,
bool  progress,
const char *  id 
)

Entry point for all thread work requests.

Definition at line 199 of file threads.cpp.

References RunThreadsOn(), and threadstate.

static void RunThreads ( void  )
static

Definition at line 137 of file threads.cpp.

References Com_CreateThread(), i, MAX_THREADS, ThreadInit(), ThreadRelease(), threadstate, and ThreadWork().

Referenced by RunThreadsOn().

void RunThreadsOn ( void(*)(unsigned int func,
int unsigned  workcount,
bool  progress,
const char *  id 
)

Entry point for all thread work requests.

Definition at line 162 of file threads.cpp.

References MAX_THREADS, RunThreads(), threadstate, VERB_NORMAL, Verb_Printf(), and WorkFunction.

Referenced by RunSingleThreadOn().

static void ThreadInit ( void  )
static

Definition at line 95 of file threads.cpp.

References lock, and Sys_Error().

Referenced by RunThreads().

void ThreadLock ( void  )

Lock the shared data by the calling thread.

Definition at line 112 of file threads.cpp.

References lock, Sys_Error(), and threadstate.

Referenced by FinalLightFace(), and GetThreadWork().

static void ThreadRelease ( void  )
static

Definition at line 103 of file threads.cpp.

References lock.

Referenced by RunThreads().

void ThreadUnlock ( void  )

Release the lock on the shared data.

Definition at line 126 of file threads.cpp.

References lock, Sys_Error(), and threadstate.

Referenced by FinalLightFace(), and GetThreadWork().

static int ThreadWork ( void p)
static

Shared work entry point by all threads. Retrieve and perform chunks of work iteratively until work is finished.

Definition at line 80 of file threads.cpp.

References GetThreadWork(), and WorkFunction.

Referenced by RunThreads().

Variable Documentation

SDL_mutex* lock = nullptr
static

Definition at line 93 of file threads.cpp.

Referenced by ThreadInit(), ThreadLock(), ThreadRelease(), and ThreadUnlock().

void(* WorkFunction)(unsigned int)
static

Generic function pointer to actual work to be done.

Definition at line 73 of file threads.cpp.

Referenced by RunThreadsOn(), and ThreadWork().