base_thread.hh File Reference

Thread class to schedule threads and abstract OS thread library. More...

#include "base_thread_common.hh"

Go to the source code of this file.

Namespaces

namespace  base

Classes

class  base::Thread
 Schedules threads and wraps OS thread library. More...
struct  base::Thread::Tid
 Thread ID (opaque). More...
struct  base::Thread::RunArgs
 Args for Thread::Run(). More...
class  base::Thread::Condition
 Wait-on-condition. More...

Defines

#define BASE_THREAD_HH   1
#define gThread   base::global.mThread
#define FN_MAIN_THREAD
#define FN_REENTRANT
#define FN_LOCKED
#define THREAD_CODE(CODE)   CODE
#define THREAD_RUN(func, funcArg, priority)   gThread.Run( (func), (funcArg), (priority) )
#define THREAD_ATOMIC_TID()   ( pthread_self() )
#define THREAD_ATOMIC_TID_EQUAL(TID)   ( pthread_equal( pthread_self(), (TID) ) )

Functions

void * base::SuballocateThreadMemory (const uint bytes)


Detailed Description

Thread class to schedule threads and abstract OS thread library.

Id
LastChangedDate

Author:
Jim E. Brooks http://www.palomino3d.org
 *
 * Usage:
 * ------
 *
 * Wrap all thread code inside THREAD_CODE().
 * Exceptions are THREAD_RUN() and PerThreadPtr.
 * These macros are for compiling single-threaded and searchability.
 *
 * Be careful not to put code that's needed for single-thread too inside THREAD_CODE():
 * //THREAD_CODE( Atomic::Add(mObjectCnt); )  ## bug
 *
 * void Enqueue( void* userdata )
 * {
 *     // Expands to nothing if COMPILE_THREADS=0
 *     THREAD_CODE( AutoSlowLock lock( &sLock ); )  // macro
 * }
 *
 * void Produce( void )
 * {
 *     // Expands as a function call "Enqueue(userdata);" if COMPILE_THREADS=0
 *     THREAD_RUN( Enqueue, userdata );  // macro
 * }
 *
 * Design:
 * -------
 *
 * Thread support is provided as separate classes:
 * - Atomic          atomic operations
 * - Lock            synchronization objects
 * - PerThreadPtr    per-thread objects (thread local storage)
 * - Thread          schedules threads, based on POSIX pthread
 * - Threadable      empty base classes to mark level of thread-safety.
 *   SemiThreadable
 *   NonThreadable
 *
 * Implementation is based on POSIX pthread but interfaces are neutral.
 *
 * GNU gcc Thread Local Storage (TLS):
 * -----------------------------------
 * System versions that introduced it (around 2003):
 * Linux with gcc 3.3
 * FreeBSD 5.3
 *
 * 

Define Documentation

#define BASE_THREAD_HH   1

#define FN_LOCKED

#define FN_MAIN_THREAD

#define FN_REENTRANT

#define gThread   base::global.mThread

 
#define THREAD_ATOMIC_TID (  )     ( pthread_self() )

#define THREAD_ATOMIC_TID_EQUAL ( TID   )     ( pthread_equal( pthread_self(), (TID) ) )

#define THREAD_CODE ( CODE   )     CODE

#define THREAD_RUN ( func,
funcArg,
priority   )     gThread.Run( (func), (funcArg), (priority) )

Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:14 2007