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, GetThreadWork(), threadstate_t::progress, ThreadLock(), threadstate, ThreadUnlock(), threadstate_t::workcount, threadstate_t::workfrac, threadstate_t::workindex, and threadstate_t::worktick.

Referenced by GetThreadWork(), and 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 threadstate_t::numthreads, RunSingleThreadOn(), RunThreadsOn(), and threadstate.

◆ RunThreads()

void RunThreads ( void )
static

◆ RunThreadsOn()

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

◆ ThreadInit()

void ThreadInit ( void )
static

Definition at line 95 of file threads.cpp.

References lock, Sys_Error(), and ThreadInit().

Referenced by RunThreads(), and ThreadInit().

◆ ThreadLock()

void ThreadLock ( void )

Lock the shared data by the calling thread.

Definition at line 112 of file threads.cpp.

References lock, threadstate_t::numthreads, Sys_Error(), ThreadLock(), and threadstate.

Referenced by FinalLightFace(), GetThreadWork(), and ThreadLock().

◆ ThreadRelease()

void ThreadRelease ( void )
static

Definition at line 103 of file threads.cpp.

References lock, and ThreadRelease().

Referenced by RunThreads(), and ThreadRelease().

◆ ThreadUnlock()

void ThreadUnlock ( void )

Release the lock on the shared data.

Definition at line 126 of file threads.cpp.

References lock, threadstate_t::numthreads, Sys_Error(), threadstate, and ThreadUnlock().

Referenced by FinalLightFace(), GetThreadWork(), and ThreadUnlock().

◆ 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(), ThreadWork(), and WorkFunction.

Referenced by RunThreads(), and ThreadWork().

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