Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

threads.c File Reference

#include "cmdlib.h"
#include "threads.h"

Include dependency graph for threads.c:

Include dependency graph

Go to the source code of this file.

Defines

#define MAX_THREADS   64

Functions

int GetThreadWork (void)
void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int))
void RunThreadsOnIndividual (int workcnt, qboolean showpacifier, void(*func)(int))
void ThreadLock (void)
void ThreadSetDefault (void)
void ThreadUnlock (void)
void ThreadWorkerFunction (int threadnum)

Variables

int dispatch
int numthreads = 1
int oldf
qboolean pacifier
qboolean threaded
int workcount
void(* workfunction )(int)


Define Documentation

#define MAX_THREADS   64
 

Definition at line 26 of file threads.c.


Function Documentation

int GetThreadWork void   ) 
 

Definition at line 41 of file threads.c.

References _printf(), dispatch, f, oldf, printf(), r, ThreadLock(), and ThreadUnlock().

00042 {
00043     int r;
00044     int f;
00045 
00046     ThreadLock ();
00047 
00048     if (dispatch == workcount)
00049     {
00050         ThreadUnlock ();
00051         return -1;
00052     }
00053 
00054     f = 10*dispatch / workcount;
00055     if (f != oldf)
00056     {
00057         oldf = f;
00058         if (pacifier)
00059             _printf ("%i...", f);
00060     }
00061 
00062     r = dispatch;
00063     dispatch++;
00064     ThreadUnlock ();
00065 
00066     return r;
00067 }

Here is the call graph for this function:

void RunThreadsOn int  workcnt,
qboolean  showpacifier,
void(*)(int)  func
 

Definition at line 424 of file threads.c.

References _printf(), dispatch, func(), I_FloatTime(), Log_Print(), NULL, oldf, pacifier, printf(), setbuf(), stdout, and workcount.

Referenced by RunThreadsOnIndividual().

00425 {
00426     int     i;
00427     int     start, end;
00428 
00429     dispatch = 0;
00430     workcount = workcnt;
00431     oldf = -1;
00432     pacifier = showpacifier;
00433     start = I_FloatTime (); 
00434     func(0);
00435 
00436     end = I_FloatTime ();
00437     if (pacifier)
00438         _printf (" (%i)\n", end-start);
00439 }

Here is the call graph for this function:

void RunThreadsOnIndividual int  workcnt,
qboolean  showpacifier,
void(*)(int)  func
 

Definition at line 86 of file threads.c.

References numthreads, RunThreadsOn(), ThreadSetDefault(), ThreadWorkerFunction(), and workfunction.

Referenced by CalcPassagePortalVis(), CalcPassageVis(), CalcPortalVis(), CalcVis(), GridAndVertexLighting(), LightWorld(), VL_DoForcedTraceLightSurfaces(), VL_LightWorld(), VL_Radiosity(), VS_DoForcedTraceLightSurfaces(), VS_LightWorld(), and VS_Radiosity().

00087 {
00088     if (numthreads == -1)
00089         ThreadSetDefault ();
00090     workfunction = func;
00091     RunThreadsOn (workcnt, showpacifier, ThreadWorkerFunction);
00092 }

Here is the call graph for this function:

void ThreadLock void   ) 
 

Definition at line 411 of file threads.c.

00412 {
00413 }

void ThreadSetDefault void   ) 
 

Definition at line 406 of file threads.c.

References numthreads.

00407 {
00408     numthreads = 1;
00409 }

void ThreadUnlock void   ) 
 

Definition at line 415 of file threads.c.

00416 {
00417 }

void ThreadWorkerFunction int  threadnum  ) 
 

Definition at line 72 of file threads.c.

References GetThreadWork(), and workfunction.

00073 {
00074     int     work;
00075 
00076     while (1)
00077     {
00078         work = GetThreadWork ();
00079         if (work == -1)
00080             break;
00081 //_printf ("thread %i, work %i\n", threadnum, work);
00082         workfunction(work);
00083     }
00084 }

Here is the call graph for this function:


Variable Documentation

int dispatch
 

Definition at line 28 of file threads.c.

int numthreads = 1
 

Definition at line 404 of file threads.c.

int oldf
 

Definition at line 30 of file threads.c.

qboolean pacifier
 

Definition at line 31 of file threads.c.

qboolean threaded
 

Definition at line 33 of file threads.c.

int workcount
 

Definition at line 29 of file threads.c.

void(* workfunction)(int)
 

Definition at line 70 of file threads.c.

Referenced by ThreadWorkerFunction().


Generated on Thu Aug 25 15:46:59 2005 for Quake III Arena by  doxygen 1.3.9.1