Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::BaseThread Class Reference
[Multithreading]

#include <OSGBaseThread.h>

Inheritance diagram for osg::BaseThread:

osg::BasePThreadBase osg::BaseThreadCommonBase osg::MPBase osg::MemoryObject osg::ThreadCommonBase osg::PThreadBase osg::ExternalThread osg::Thread List of all members.

Get

*static BaseThreadget (const Char8 *szName)
static BaseThreadfind (const Char8 *szName)
static BaseThreadcreate (void)
static const MPThreadTypegetClassType (void)

Construction

*virtual void init (void)
void setupThread (void)
void setupBlockCond (void)

Class Specific

*static BaseThreadcreate (const Char8 *szName, UInt32 uiId)
static void initThreading (void)
static void runWorkProc (void *pThread)

Public Types

typedef MPThreadType Type
typedef void(* ThreadFuncF )(void *pThreadArg)

Public Member Functions

bool isInitialized (void)

Static Public Member Functions

Get
*static BaseThreadgetCurrent (void)

Protected Member Functions

Constructors
BaseThread (const Char8 *szName, UInt32 uiId)
Destructors
*virtual ~BaseThread (void)

Protected Attributes

UInt32 _uiThreadId
bool _bInitialized

Static Protected Attributes

static MPThreadType _type
static pthread_key_t _threadKey

Private Types

typedef BaseThreadBase Inherited

Private Member Functions

 BaseThread (const BaseThread &source)
 prohibit default function (move to 'public' if needed)
void operator= (const BaseThread &source)
 prohibit default function (move to 'public' if needed)

Friends

class ThreadManager
class MPFieldStore< BaseThread >

Detailed Description

Definition at line 553 of file OSGBaseThread.h.


Member Typedef Documentation

typedef BaseThreadBase osg::BaseThread::Inherited [private]
 

Reimplemented from osg::BasePThreadBase.

Reimplemented in osg::ThreadCommonBase, osg::PThreadBase, osg::Thread, and osg::ExternalThread.

Definition at line 559 of file OSGBaseThread.h.

typedef MPThreadType osg::BaseThread::Type
 

Reimplemented in osg::Thread, and osg::ExternalThread.

Definition at line 565 of file OSGBaseThread.h.

typedef void(* osg::BaseThreadCommonBase::ThreadFuncF)(void *pThreadArg) [inherited]
 

Definition at line 90 of file OSGBaseThread.h.


Constructor & Destructor Documentation

BaseThread::BaseThread const Char8 szName,
UInt32  uiId
[protected]
 

Definition at line 876 of file OSGBaseThread.cpp.

Referenced by create().

00876                                                        :
00877     Inherited(szName, uiId)
00878 {
00879 }

BaseThread::~BaseThread void   )  [protected, virtual]
 

Definition at line 883 of file OSGBaseThread.cpp.

References osg::ThreadManager::getAppThread(), osg::ThreadManager::removeThread(), terminate(), and osg::ThreadManager::the().

00884 {
00885     ThreadManager::the()->removeThread(this);
00886 
00887     if(this != ThreadManager::getAppThread())
00888         terminate();
00889 }

osg::BaseThread::BaseThread const BaseThread source  )  [private]
 


Member Function Documentation

BaseThread * BaseThread::get const Char8 szName  )  [static]
 

Reimplemented in osg::Thread, and osg::ExternalThread.

Definition at line 752 of file OSGBaseThread.cpp.

References osg::ThreadManager::getThread(), and osg::ThreadManager::the().

Referenced by create(), osg::PointMCastConnection::initialize(), and osg::GroupMCastConnection::initialize().

00753 {
00754     return ThreadManager::the()->getThread(szName, "OSGBaseThread");
00755 }

BaseThread * BaseThread::find const Char8 szName  )  [static]
 

Reimplemented in osg::Thread, and osg::ExternalThread.

Definition at line 757 of file OSGBaseThread.cpp.

References osg::ThreadManager::findThread(), and osg::ThreadManager::the().

00758 {
00759     return ThreadManager::the()->findThread(szName);
00760 }

BaseThread * BaseThread::create void   )  [static]
 

Definition at line 762 of file OSGBaseThread.cpp.

References get().

00763 {
00764     return BaseThread::get(NULL);
00765 }

const MPThreadType & BaseThread::getClassType void   )  [static]
 

Definition at line 767 of file OSGBaseThread.cpp.

References _type.

Referenced by osg::ThreadManager::init().

00768 {
00769     return _type;
00770 }

BaseThread * BaseThread::getCurrent void   )  [static]
 

Reimplemented from osg::BasePThreadBase.

Reimplemented in osg::Thread, and osg::ExternalThread.

Definition at line 774 of file OSGBaseThread.cpp.

References osg::Directory::getCurrent().

00775 {
00776     return Inherited::getCurrent();
00777 }

void BaseThread::join BaseThread pThread  )  [static]
 

Definition at line 781 of file OSGBaseThread.cpp.

References osg::BasePThreadBase::join().

Referenced by osg::ProxyGroup::draw(), osg::ProxyGroup::startLoading(), osg::SceneFileHandler::stopReadProgressThread(), osg::GroupMCastConnection::write(), osg::GroupMCastConnection::~GroupMCastConnection(), and osg::PointMCastConnection::~PointMCastConnection().

00782 {
00783     Inherited::join(pThread);
00784 }

void BaseThread::run void   ) 
 

Definition at line 789 of file OSGBaseThread.cpp.

References osg::BasePThreadBase::runFunction(), and runWorkProc().

00790 {
00791     Inherited::runFunction(runWorkProc, this);
00792 }

bool BaseThread::runFunction ThreadFuncF  fThreadFunc,
void *  pThreadArg
 

Reimplemented from osg::BasePThreadBase.

Definition at line 794 of file OSGBaseThread.cpp.

References osg::BasePThreadBase::runFunction().

Referenced by osg::PointMCastConnection::initialize(), osg::GroupMCastConnection::initialize(), and osg::PThreadBase::runFunction().

00796 {
00797     return Inherited::runFunction(fThreadFunc, pThreadArg);
00798 }

void BaseThread::block void   ) 
 

Reimplemented from osg::BasePThreadBase.

Definition at line 802 of file OSGBaseThread.cpp.

References osg::BasePThreadBase::block().

00803 {
00804     Inherited::block();
00805 }

void BaseThread::unblock void   ) 
 

Reimplemented from osg::BasePThreadBase.

Definition at line 807 of file OSGBaseThread.cpp.

References osg::BasePThreadBase::unblock().

00808 {
00809     Inherited::unblock();
00810 }

bool BaseThread::exists void   ) 
 

Reimplemented from osg::BasePThreadBase.

Definition at line 814 of file OSGBaseThread.cpp.

References osg::BasePThreadBase::exists().

00815 {
00816     return Inherited::exists();
00817 }

void BaseThread::terminate void   ) 
 

Reimplemented from osg::BasePThreadBase.

Definition at line 820 of file OSGBaseThread.cpp.

References osg::BasePThreadBase::terminate().

Referenced by ~BaseThread().

00821 {
00822     Inherited::terminate();
00823 }

void BaseThread::kill void   ) 
 

Reimplemented from osg::BasePThreadBase.

Definition at line 825 of file OSGBaseThread.cpp.

References osg::BasePThreadBase::kill().

00826 {
00827     Inherited::kill();
00828 }

void BaseThread::print void   ) 
 

Reimplemented from osg::BasePThreadBase.

Definition at line 832 of file OSGBaseThread.cpp.

References osg::BasePThreadBase::print().

00833 {
00834     Inherited::print();
00835 }

BaseThread * BaseThread::create const Char8 szName,
UInt32  uiId
[static, protected]
 

Reimplemented in osg::Thread, and osg::ExternalThread.

Definition at line 839 of file OSGBaseThread.cpp.

References BaseThread().

00840 {
00841     return new BaseThread(szName, uiId);
00842 }

void BaseThread::initThreading void   )  [static, protected]
 

Reimplemented in osg::Thread.

Definition at line 844 of file OSGBaseThread.cpp.

References osg::BasePThreadBase::_threadKey, FFASSERT, FINFO, and osg::BasePThreadBase::freeThread().

00845 {
00846     FINFO(("BaseThread::initThreading\n"))
00847 
00848 #if defined(OSG_USE_PTHREADS) && !defined(OSG_PTHREAD_ELF_TLS)
00849     int rc;
00850 
00851     rc = pthread_key_create(&(BaseThread::_threadKey),
00852                               BaseThread::freeThread);
00853 
00854     FFASSERT((rc == 0), 1, ("Failed to create pthread thread key\n");)
00855 #endif
00856 
00857 #if defined(OSG_USE_WINTHREADS) && defined (OSG_ASPECT_USE_LOCALSTORAGE)
00858     BaseThread::_threadKey     = TlsAlloc();
00859 
00860     FFASSERT((BaseThread::_threadKey != 0xFFFFFFFF), 1,
00861              ("Failed to alloc thread key local storage\n");)
00862 #endif
00863 }

void BaseThread::runWorkProc void *  pThread  )  [static, protected]
 

Definition at line 865 of file OSGBaseThread.cpp.

Referenced by osg::Thread::run(), and run().

00866 {
00867     if(pThread != NULL)
00868     {
00869         static_cast<BaseThread *>(pThread)->workProc();
00870     }
00871 }

void BaseThread::workProc void   )  [protected, virtual]
 

Definition at line 893 of file OSGBaseThread.cpp.

00894 {
00895 }

void osg::BaseThread::operator= const BaseThread source  )  [private]
 

void * BasePThreadBase::threadFunc void *  pThreadArg  )  [static, protected, inherited]
 

Definition at line 114 of file OSGBaseThread.cpp.

Referenced by osg::BasePThreadBase::runFunction().

00115 {
00116     void **pArgs = (void **) pThreadArg;
00117 
00118     if(pArgs != NULL)
00119     {
00120         if(pArgs[2] != NULL)
00121         {
00122             ((BaseThread *) pArgs[2])->init();
00123 
00124             if(pArgs[0] != NULL)
00125             {
00126                 ThreadFuncF fThreadFunc = (ThreadFuncF) pArgs[0];
00127 
00128                 fThreadFunc(pArgs[1]);
00129             }
00130         }
00131     }
00132 
00133     return NULL;
00134 }

void BasePThreadBase::freeThread void *  pThread  )  [static, protected, inherited]
 

Definition at line 137 of file OSGBaseThread.cpp.

Referenced by initThreading(), and osg::ThreadManager::shutdown().

00138 {
00139     BaseThread **pT = static_cast<BaseThread **>(pThread);
00140 
00141     delete pT;
00142 }

void BasePThreadBase::init void   )  [protected, virtual, inherited]
 

Reimplemented in osg::PThreadBase.

Definition at line 193 of file OSGBaseThread.cpp.

References osg::BaseThreadCommonBase::_bInitialized, osg::BasePThreadBase::setupBlockCond(), and osg::BasePThreadBase::setupThread().

Referenced by osg::ThreadManager::init().

00194 {
00195     if(_bInitialized == true)
00196         return;
00197 
00198     setupThread    ();
00199     setupBlockCond ();
00200 
00201     _bInitialized = true;
00202 }

void BasePThreadBase::setupThread void   )  [protected, inherited]
 

Definition at line 171 of file OSGBaseThread.cpp.

References osg::BasePThreadBase::_threadKey.

Referenced by osg::BasePThreadBase::init().

00172 {
00173 #ifdef OSG_PTHREAD_ELF_TLS
00174     _pLocalThread = static_cast<BaseThread *>(this);
00175 #else
00176     BaseThread **pThread = new BaseThread *;
00177 
00178     *pThread = (BaseThread *) this;
00179 
00180     pthread_setspecific(_threadKey, (void *) pThread);
00181 #endif
00182 }

void BasePThreadBase::setupBlockCond void   )  [protected, inherited]
 

Definition at line 184 of file OSGBaseThread.cpp.

References osg::BasePThreadBase::_pBlockCond, and osg::BasePThreadBase::_pBlockMutex.

Referenced by osg::BasePThreadBase::init().

00185 {
00186     _pBlockCond  = new pthread_cond_t;
00187     _pBlockMutex = new pthread_mutex_t;
00188 
00189     pthread_cond_init (_pBlockCond, NULL);
00190     pthread_mutex_init(_pBlockMutex, NULL);
00191 }

void BasePThreadBase::join BasePThreadBase threadP  )  [static, protected, inherited]
 

Definition at line 221 of file OSGBaseThread.cpp.

References osg::BasePThreadBase::_pThreadDesc.

Referenced by join().

00222 {
00223     if(pThread != NULL && pThread->_pThreadDesc != NULL)
00224     {
00225         pthread_join(*(pThread->_pThreadDesc), NULL);
00226     }
00227 }

bool BaseThreadCommonBase::isInitialized void   )  [inherited]
 

Definition at line 73 of file OSGBaseThread.cpp.

References osg::BaseThreadCommonBase::_bInitialized.

00074 {
00075     return _bInitialized;
00076 }

const MPType & MPBase::getStaticType void   )  [static, inherited]
 

Definition at line 253 of file OSGMPBase.cpp.

References osg::MPBase::_type.

00254 {
00255     return _type;
00256 }

UInt32 MPBase::getStaticTypeId void   )  [static, inherited]
 

Definition at line 259 of file OSGMPBase.cpp.

00260 {
00261     return 0;
00262 }

MPType & MPBase::getType void   )  [virtual, inherited]
 

Definition at line 265 of file OSGMPBase.cpp.

References osg::MPBase::_type.

Referenced by osg::MPBase::getTypeId().

00266 {
00267     return _type;
00268 }

const MPType & MPBase::getType void   )  const [virtual, inherited]
 

Definition at line 271 of file OSGMPBase.cpp.

References osg::MPBase::_type.

00272 {
00273     return _type;
00274 }

UInt32 MPBase::getTypeId void   )  [inherited]
 

Definition at line 277 of file OSGMPBase.cpp.

References osg::TypeBase::getId(), and osg::MPBase::getType().

00278 {
00279     return getType().getId();
00280 }

const Char8 * MPBase::getCName void   )  const [inherited]
 

Definition at line 283 of file OSGMPBase.cpp.

References osg::MPBase::_szName.

00284 {
00285     return _szName;
00286 }

void MemoryObject::addRef void   )  [inherited]
 

Definition at line 64 of file OSGMemoryObject.cpp.

References osg::MemoryObject::_refCount.

Referenced by osg::SharedObjectHandler::getSharedObject(), and osg::SharedObjectHandler::initialize().

00065 {
00066     _refCount++;
00067 }

void MemoryObject::subRef void   )  [inherited]
 

Definition at line 69 of file OSGMemoryObject.cpp.

References osg::MemoryObject::_refCount.

00070 {
00071     _refCount--;
00072 
00073     if(_refCount <= 0)
00074         delete this;
00075 }

Int32 MemoryObject::getRefCount void   )  [inherited]
 

Definition at line 77 of file OSGMemoryObject.cpp.

References osg::MemoryObject::_refCount.

00078 {
00079     return _refCount;
00080 }


Friends And Related Function Documentation

friend class ThreadManager [friend]
 

Reimplemented from osg::BasePThreadBase.

Reimplemented in osg::ThreadCommonBase, osg::PThreadBase, osg::Thread, and osg::ExternalThread.

Definition at line 669 of file OSGBaseThread.h.

friend class MPFieldStore< BaseThread > [friend]
 

Reimplemented in osg::Thread, and osg::ExternalThread.

Definition at line 670 of file OSGBaseThread.h.


Member Data Documentation

MPThreadType BaseThread::_type [static, protected]
 

Reimplemented from osg::MPBase.

Reimplemented in osg::Thread, and osg::ExternalThread.

Referenced by getClassType().

pthread_key_t BasePThreadBase::_threadKey [static, protected, inherited]
 

Definition at line 107 of file OSGBaseThread.cpp.

Referenced by osg::BasePThreadBase::getCurrent(), initThreading(), and osg::BasePThreadBase::setupThread().

* void* osg::BasePThreadBase::_pThreadData[3] [protected, inherited]
 

Definition at line 174 of file OSGBaseThread.h.

Referenced by osg::BasePThreadBase::BasePThreadBase(), and osg::BasePThreadBase::runFunction().

pthread_t* osg::BasePThreadBase::_pThreadDesc [protected, inherited]
 

Definition at line 175 of file OSGBaseThread.h.

Referenced by osg::BasePThreadBase::join(), osg::BasePThreadBase::kill(), osg::BasePThreadBase::runFunction(), osg::BasePThreadBase::terminate(), and osg::BasePThreadBase::~BasePThreadBase().

pthread_cond_t* osg::BasePThreadBase::_pBlockCond [protected, inherited]
 

Definition at line 177 of file OSGBaseThread.h.

Referenced by osg::BasePThreadBase::block(), osg::BasePThreadBase::setupBlockCond(), and osg::BasePThreadBase::unblock().

pthread_mutex_t* osg::BasePThreadBase::_pBlockMutex [protected, inherited]
 

Definition at line 178 of file OSGBaseThread.h.

Referenced by osg::BasePThreadBase::block(), and osg::BasePThreadBase::setupBlockCond().

UInt32 osg::BaseThreadCommonBase::_uiThreadId [protected, inherited]
 

Definition at line 100 of file OSGBaseThread.h.

Referenced by osg::BasePThreadBase::print().

bool osg::BaseThreadCommonBase::_bInitialized [protected, inherited]
 

Definition at line 101 of file OSGBaseThread.h.

Referenced by osg::PThreadBase::init(), osg::BasePThreadBase::init(), osg::ExternalThread::initialize(), osg::BaseThreadCommonBase::isInitialized(), and osg::BasePThreadBase::runFunction().

Char8* osg::MPBase::_szName [protected, inherited]
 

Definition at line 406 of file OSGMPBase.h.

Referenced by osg::MPBase::getCName(), osg::LockPool::init(), osg::MPBase::MPBase(), osg::BasePThreadBase::print(), and osg::MPBase::~MPBase().


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 04:12:32 2005 for OpenSG by  doxygen 1.4.3