UFO: Alien Invasion
Loading...
Searching...
No Matches
threads.cpp File Reference
#include "bsp.h"
#include "../../shared/thread.h"
Include dependency graph for threads.cpp:

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.
static int ThreadWork (void *p)
 Shared work entry point by all threads. Retrieve and perform chunks of work iteratively until work is finished.
static void ThreadInit (void)
static void ThreadRelease (void)
void ThreadLock (void)
 Lock the shared data by the calling thread.
void ThreadUnlock (void)
 Release the lock on the shared data.
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.
void RunSingleThreadOn (void(*func)(unsigned int), int unsigned workcount, bool progress, const char *id)
 Entry point for all thread work requests.

Variables

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

Macro Definition Documentation

◆ MAX_THREADS

#define MAX_THREADS   8

Definition at line 30 of file threads.cpp.

Referenced by RunThreads(), and RunThreadsOn().

Function Documentation

◆ GetThreadWork()

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().

◆ RunSingleThreadOn()

void RunSingleThreadOn ( void(* func )(unsigned int),
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.

◆ RunThreads()

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().

◆ RunThreadsOn()

void RunThreadsOn ( void(* func )(unsigned int),
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().

◆ ThreadInit()

void ThreadInit ( void )
static

Definition at line 95 of file threads.cpp.

References lock, and Sys_Error().

Referenced by RunThreads().

◆ ThreadLock()

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().

◆ ThreadRelease()

void ThreadRelease ( void )
static

Definition at line 103 of file threads.cpp.

References lock.

Referenced by RunThreads().

◆ ThreadUnlock()

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().

◆ ThreadWork()

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

◆ lock

SDL_mutex* lock = nullptr
static

Definition at line 93 of file threads.cpp.

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

◆ threadstate

◆ WorkFunction

void(* WorkFunction) (unsigned int) ( 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().