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

Thread Class Reference

#include <Thread.h>

Inheritance diagram for Thread:

Inheritance graph
[legend]

Public Member Functions

 Thread (void)
 Thread (THREAD_START aExternalRoutine)
 ~Thread ()
SDL_Thread * GetHandle (void)
const bool Start (void *aArg=NULL)
void Stop (void)
long GetExitCode () const
int Wait (void)
void Attach (THREAD_START lpThreadFunc)
void Detach (void)
virtual long Run (void *)
virtual void ThreadCtor ()
virtual void ThreadDtor ()

Static Protected Member Functions

int __cdecl EntryPoint (void *pArg)

Protected Attributes

SDL_Thread * tid
THREAD_START threadFunc
long threadReturnCode
void * arg

Constructor & Destructor Documentation

Thread::Thread void   )  [inline]
 

Definition at line 24 of file Thread.h.

References arg, EntryPoint(), THREAD_START, threadFunc, threadReturnCode, and tid.

00025         : tid( 0 ) , threadReturnCode( -1 ) , arg( 0 )
00026         { 
00027                 threadFunc = (THREAD_START)Thread::EntryPoint; // Can call Detach() also.
00028         }

Thread::Thread THREAD_START  aExternalRoutine  )  [inline]
 

Definition at line 36 of file Thread.h.

References arg, Attach(), threadReturnCode, and tid.

00037         : tid( 0 ) , threadReturnCode( -1 ) , arg( 0 )
00038         {
00039                 Attach( aExternalRoutine );
00040         }

Thread::~Thread  )  [inline]
 

Definition at line 48 of file Thread.h.

References tid.

00049         {
00050                 if( tid )
00051                         SDL_KillThread( tid );
00052                 //      if ( m_ThreadCtx.m_hThread )    Stop(true);
00053         }


Member Function Documentation

void Thread::Attach THREAD_START  lpThreadFunc  )  [inline]
 

Definition at line 100 of file Thread.h.

References threadFunc.

Referenced by Thread().

00100 {       threadFunc = lpThreadFunc;      }

void Thread::Detach void   )  [inline]
 

Definition at line 108 of file Thread.h.

References EntryPoint(), and threadFunc.

int __cdecl Thread::EntryPoint void *  pArg  )  [inline, static, protected]
 

Definition at line 121 of file Thread.h.

References __cdecl, arg, Run(), ThreadCtor(), ThreadDtor(), and threadReturnCode.

Referenced by Detach(), and Thread().

00122         {
00123                 Thread *pParent = reinterpret_cast<Thread*>( pArg );
00124 
00125                 pParent->ThreadCtor();
00126 
00127                 pParent->threadReturnCode = pParent->Run( pParent->arg );
00128 
00129                 pParent->ThreadDtor();
00130 
00131                 return 0;
00132         }

long Thread::GetExitCode  )  const [inline]
 

Definition at line 84 of file Thread.h.

References threadReturnCode.

Referenced by Wait().

00085         { 
00086                 return threadReturnCode;
00087         }

SDL_Thread* Thread::GetHandle void   )  [inline]
 

Definition at line 58 of file Thread.h.

References tid.

Referenced by Wait().

00058 {       return tid;     }

virtual long Thread::Run void *   )  [inline, virtual]
 

Reimplemented in SetupGalaxyScreen, LoadGalaxyData, InitGalaxyScreen, InitStarInfo, InitStarName, InitPlanetInfo, InitSpecies, InitPlanetSize, InitEcoZone, and Galaxy.

Definition at line 143 of file Thread.h.

Referenced by EntryPoint().

00143 { return 0; }

const bool Thread::Start void *  aArg = NULL  )  [inline]
 

Definition at line 65 of file Thread.h.

References arg, threadFunc, threadReturnCode, and tid.

Referenced by Galaxy::evMessage().

00066         {
00067                 tid = SDL_CreateThread( threadFunc , this );            //      CreateThread(NULL, 0, m_pThreadFunc, this, 0, &m_ThreadCtx.m_dwTID);
00068                 threadReturnCode = 0;
00069                 arg = aArg;
00070                 return tid != 0;
00071         }

void Thread::Stop void   )  [inline]
 

Definition at line 73 of file Thread.h.

References tid.

00074         {
00075                 if( tid )
00076                         SDL_KillThread( tid );
00077                 tid = 0;
00078         }

virtual void Thread::ThreadCtor  )  [inline, virtual]
 

Definition at line 153 of file Thread.h.

Referenced by EntryPoint().

00153 {       }

virtual void Thread::ThreadDtor  )  [inline, virtual]
 

Definition at line 163 of file Thread.h.

References tid.

Referenced by EntryPoint().

00163 {       tid = 0;        }

int Thread::Wait void   )  [inline]
 

Definition at line 89 of file Thread.h.

References GetExitCode(), GetHandle(), threadReturnCode, and tid.

00090         {
00091                 SDL_WaitThread( GetHandle() , (int *)&threadReturnCode );
00092                 tid = 0;
00093                 return GetExitCode();
00094 
00095         }


Field Documentation

void* Thread::arg [protected]
 

Definition at line 18 of file Thread.h.

Referenced by EntryPoint(), Galaxy::Run(), Start(), and Thread().

THREAD_START Thread::threadFunc [protected]
 

Definition at line 15 of file Thread.h.

Referenced by Attach(), Detach(), Start(), and Thread().

long Thread::threadReturnCode [protected]
 

Definition at line 17 of file Thread.h.

Referenced by EntryPoint(), GetExitCode(), Start(), Thread(), and Wait().

SDL_Thread* Thread::tid [protected]
 

Definition at line 13 of file Thread.h.

Referenced by GetHandle(), Start(), Stop(), Thread(), ThreadDtor(), Wait(), and ~Thread().


The documentation for this class was generated from the following file:
Generated on Fri Dec 5 04:06:39 2003 for Borqueror by doxygen 1.3.3