#include <OSGBaseThread.h>

Class Specific | |
| static MPType | _type |
| Char8 * | _szName |
Public Types | |
| typedef void(* | ThreadFuncF )(void *pThreadArg) |
Public Member Functions | |
| bool | isInitialized (void) |
Get | |
| virtual MPType & | getType (void) |
| virtual const MPType & | getType (void) const |
| UInt32 | getTypeId (void) |
| const Char8 * | getCName (void) const |
Reference Counting | |
| void | addRef (void) |
| void | subRef (void) |
| Int32 | getRefCount (void) |
Static Public Member Functions | |
Class Get | |
| static const MPType & | getStaticType (void) |
| static UInt32 | getStaticTypeId (void) |
Protected Types | |
| typedef BaseThreadCommonBase | Inherited |
Protected Member Functions | |
Constructors | |
| BasePThreadBase (const Char8 *szName, UInt32 uiId) | |
Destructors | |
| virtual | ~BasePThreadBase (void) |
Construction | |
| virtual void | init (void) |
| void | setupThread (void) |
| void | setupBlockCond (void) |
Run | |
| bool | runFunction (ThreadFuncF fThreadFunc, void *pThreadArg) |
Blocking | |
| void | block (void) |
| void | unblock (void) |
Helper | |
| bool | exists (void) |
| void | terminate (void) |
| void | kill (void) |
Dump | |
| void | print (void) |
Static Protected Member Functions | |
Helper | |
| static void * | threadFunc (void *pThreadArg) |
| static void | freeThread (void *pThread) |
Get | |
| static BaseThread * | getCurrent (void) |
Join | |
| static void | join (BasePThreadBase *threadP) |
Protected Attributes | |
| UInt32 | _uiThreadId |
| bool | _bInitialized |
Instance Variables | |
| void * | _pThreadData [3] |
| pthread_t * | _pThreadDesc |
| pthread_cond_t * | _pBlockCond |
| pthread_mutex_t * | _pBlockMutex |
Static Protected Attributes | |
| static pthread_key_t | _threadKey |
Private Member Functions | |
| BasePThreadBase (const BasePThreadBase &source) | |
| prohibit default function (move to 'public' if needed) | |
| void | operator= (const BasePThreadBase &source) |
| prohibit default function (move to 'public' if needed) | |
Friends | |
| class | ThreadManager |
Definition at line 141 of file OSGBaseThread.h.
typedef BaseThreadCommonBase osg::BasePThreadBase::Inherited [protected] |
Reimplemented from osg::BaseThreadCommonBase.
Reimplemented in osg::BaseThread, osg::ThreadCommonBase, osg::PThreadBase, osg::Thread, and osg::ExternalThread.
Definition at line 151 of file OSGBaseThread.h.
typedef void(* osg::BaseThreadCommonBase::ThreadFuncF)(void *pThreadArg) [inherited] |
Definition at line 147 of file OSGBaseThread.cpp.
References _pThreadData.
00148 : 00149 Inherited (szName, uiId), 00150 00151 _pThreadDesc(NULL), 00152 _pBlockCond (NULL), 00153 _pBlockMutex(NULL) 00154 { 00155 _pThreadData[0] = NULL; 00156 _pThreadData[1] = NULL; 00157 _pThreadData[2] = NULL; 00158 }
| BasePThreadBase::~BasePThreadBase | ( | void | ) | [protected, virtual] |
Definition at line 163 of file OSGBaseThread.cpp.
References _pThreadDesc.
00164 { 00165 delete _pThreadDesc; 00166 }
| osg::BasePThreadBase::BasePThreadBase | ( | const BasePThreadBase & | source | ) | [private] |
| void * BasePThreadBase::threadFunc | ( | void * | pThreadArg | ) | [static, protected] |
Definition at line 114 of file OSGBaseThread.cpp.
Referenced by 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] |
Definition at line 137 of file OSGBaseThread.cpp.
Referenced by osg::BaseThread::initThreading(), and osg::ThreadManager::shutdown().
00138 { 00139 BaseThread **pT = static_cast<BaseThread **>(pThread); 00140 00141 delete pT; 00142 }
| void BasePThreadBase::init | ( | void | ) | [protected, virtual] |
Reimplemented in osg::PThreadBase.
Definition at line 193 of file OSGBaseThread.cpp.
References osg::BaseThreadCommonBase::_bInitialized, setupBlockCond(), and 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] |
Definition at line 171 of file OSGBaseThread.cpp.
References _threadKey.
Referenced by 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] |
Definition at line 184 of file OSGBaseThread.cpp.
References _pBlockCond, and _pBlockMutex.
Referenced by 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 }
| BaseThread * BasePThreadBase::getCurrent | ( | void | ) | [static, protected] |
Reimplemented in osg::BaseThread, osg::Thread, and osg::ExternalThread.
Definition at line 206 of file OSGBaseThread.cpp.
References _threadKey.
00207 { 00208 #ifdef OSG_PTHREAD_ELF_TLS 00209 return _pLocalThread; 00210 #else 00211 BaseThread **pThread; 00212 00213 pThread = (BaseThread **) pthread_getspecific(_threadKey); 00214 00215 return *pThread; 00216 #endif 00217 }
| void BasePThreadBase::join | ( | BasePThreadBase * | threadP | ) | [static, protected] |
Definition at line 221 of file OSGBaseThread.cpp.
References _pThreadDesc.
Referenced by osg::BaseThread::join().
00222 { 00223 if(pThread != NULL && pThread->_pThreadDesc != NULL) 00224 { 00225 pthread_join(*(pThread->_pThreadDesc), NULL); 00226 } 00227 }
| bool BasePThreadBase::runFunction | ( | ThreadFuncF | fThreadFunc, | |
| void * | pThreadArg | |||
| ) | [protected] |
Reimplemented in osg::BaseThread.
Definition at line 233 of file OSGBaseThread.cpp.
References osg::BaseThreadCommonBase::_bInitialized, _pThreadData, _pThreadDesc, SFATAL, and threadFunc().
Referenced by osg::BaseThread::run(), and osg::BaseThread::runFunction().
00235 { 00236 bool returnValue = true; 00237 Int32 rc = 0; 00238 00239 _bInitialized = false; 00240 00241 if(fThreadFunc != NULL) 00242 { 00243 if(_pThreadDesc == NULL) 00244 _pThreadDesc = new pthread_t; 00245 00246 pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &rc); 00247 00248 _pThreadData[0] = (void *) fThreadFunc; 00249 _pThreadData[1] = pThreadArg; 00250 _pThreadData[2] = (void *) this; 00251 00252 pthread_attr_t threadAttr; 00253 pthread_attr_setscope(&threadAttr, PTHREAD_SCOPE_SYSTEM); 00254 00255 rc = pthread_create(_pThreadDesc, 00256 #if 0 00257 &threadAttr, 00258 #else 00259 NULL, 00260 #endif 00261 BasePThreadBase::threadFunc, 00262 (void *) &_pThreadData); 00263 00264 if(rc != 0) 00265 { 00266 SFATAL << "OSGPTB : pthread_create failed" << std::endl; 00267 returnValue = false; 00268 } 00269 } 00270 else 00271 { 00272 SFATAL << "OSGPTB : no thread function given"; 00273 returnValue = false; 00274 } 00275 00276 return returnValue; 00277 }
| void BasePThreadBase::block | ( | void | ) | [protected] |
Reimplemented in osg::BaseThread.
Definition at line 281 of file OSGBaseThread.cpp.
References _pBlockCond, and _pBlockMutex.
Referenced by osg::BaseThread::block().
00282 { 00283 pthread_mutex_lock (_pBlockMutex); 00284 pthread_cond_wait (_pBlockCond, _pBlockMutex); 00285 pthread_mutex_unlock(_pBlockMutex); 00286 }
| void BasePThreadBase::unblock | ( | void | ) | [protected] |
Reimplemented in osg::BaseThread.
Definition at line 288 of file OSGBaseThread.cpp.
References _pBlockCond.
Referenced by osg::BaseThread::unblock().
00289 { 00290 pthread_cond_broadcast(_pBlockCond); 00291 }
| bool BasePThreadBase::exists | ( | void | ) | [protected] |
Reimplemented in osg::BaseThread.
Definition at line 295 of file OSGBaseThread.cpp.
Referenced by osg::BaseThread::exists().
| void BasePThreadBase::terminate | ( | void | ) | [protected] |
Reimplemented in osg::BaseThread.
Definition at line 300 of file OSGBaseThread.cpp.
References _pThreadDesc.
Referenced by osg::BaseThread::terminate().
00301 { 00302 if(_pThreadDesc != NULL) 00303 pthread_cancel(*_pThreadDesc); 00304 }
| void BasePThreadBase::kill | ( | void | ) | [protected] |
Reimplemented in osg::BaseThread.
Definition at line 306 of file OSGBaseThread.cpp.
References _pThreadDesc.
Referenced by osg::BaseThread::kill().
00307 { 00308 if(_pThreadDesc != NULL) 00309 pthread_cancel(*_pThreadDesc); 00310 }
| void BasePThreadBase::print | ( | void | ) | [protected] |
Reimplemented in osg::BaseThread.
Definition at line 314 of file OSGBaseThread.cpp.
References osg::MPBase::_szName, and osg::BaseThreadCommonBase::_uiThreadId.
Referenced by osg::BaseThread::print().
00315 { 00316 fprintf(stderr, "OSGPThreadBase -%s-%d-\n", _szName, _uiThreadId); 00317 }
| void osg::BasePThreadBase::operator= | ( | const BasePThreadBase & | source | ) | [private] |
| 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] |
| 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().
| 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] |
| Int32 MemoryObject::getRefCount | ( | void | ) | [inherited] |
Definition at line 77 of file OSGMemoryObject.cpp.
References osg::MemoryObject::_refCount.
00078 { 00079 return _refCount; 00080 }
friend class ThreadManager [friend] |
Reimplemented from osg::BaseThreadCommonBase.
Reimplemented in osg::BaseThread, osg::ThreadCommonBase, osg::PThreadBase, osg::Thread, and osg::ExternalThread.
Definition at line 256 of file OSGBaseThread.h.
pthread_key_t BasePThreadBase::_threadKey [static, protected] |
Definition at line 156 of file OSGBaseThread.h.
Referenced by getCurrent(), osg::BaseThread::initThreading(), and setupThread().
void* osg::BasePThreadBase::_pThreadData[3] [protected] |
pthread_t* osg::BasePThreadBase::_pThreadDesc [protected] |
Definition at line 175 of file OSGBaseThread.h.
Referenced by join(), kill(), runFunction(), terminate(), and ~BasePThreadBase().
pthread_cond_t* osg::BasePThreadBase::_pBlockCond [protected] |
Definition at line 177 of file OSGBaseThread.h.
Referenced by block(), setupBlockCond(), and unblock().
pthread_mutex_t* osg::BasePThreadBase::_pBlockMutex [protected] |
UInt32 osg::BaseThreadCommonBase::_uiThreadId [protected, inherited] |
bool osg::BaseThreadCommonBase::_bInitialized [protected, inherited] |
Definition at line 101 of file OSGBaseThread.h.
Referenced by osg::PThreadBase::init(), init(), osg::ExternalThread::initialize(), osg::BaseThreadCommonBase::isInitialized(), and runFunction().
MPType MPBase::_type [static, protected, inherited] |
Reimplemented in osg::Barrier, osg::BaseThread, osg::Lock, osg::LockPool, osg::Thread, and osg::ExternalThread.
Definition at line 405 of file OSGMPBase.h.
Referenced by osg::MPBase::getStaticType(), and osg::MPBase::getType().
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(), print(), and osg::MPBase::~MPBase().
1.5.5