#include <OSGThreadManager.h>
Types | |
| typedef MPFieldStore< Barrier > | BarrierStore |
| typedef MPFieldStore< Lock > | LockStore |
| typedef MPFieldStore< LockPool > | LockPoolStore |
| *typedef MPFieldStore< BaseThread > | ThreadStore |
Friend Classes | |
| *friend class | MPThreadType |
| class | MPBarrierType |
| class | MPLockType |
| class | MPLockPoolType |
| class | BaseThread |
| class | Barrier |
| class | Lock |
| class | LockPool |
| bool | osgInit (Int32 argc, Char8 **argv) |
| bool | osgExit (void) |
Instance Variables | |
| *ThreadStore | _sThreadStore |
| BarrierStore | _sBarrierStore |
| LockStore | _sLockStore |
| LockPoolStore | _sLockPoolStore |
| Lock * | _storePLock |
| static Char8 * | _szAppThreadType = NULL |
Public Member Functions | |
Create Threading Element | |
| *BaseThread * | getThread (const Char8 *szName, const Char8 *szTypeName="OSGThread") |
| Barrier * | getBarrier (const Char8 *szName, const Char8 *szTypeName="OSGBarrier") |
| Lock * | getLock (const Char8 *szName, const Char8 *szTypeName="OSGLock") |
| LockPool * | getLockPool (const Char8 *szName, const Char8 *szTypeName="OSGLockPool") |
| BaseThread * | findThread (const Char8 *szName) |
| Barrier * | findBarrier (const Char8 *szName) |
| Lock * | findLock (const Char8 *szName) |
| LockPool * | findLockPool (const Char8 *szName) |
Static Public Member Functions | |
Set / Get | |
| *static void | setAppThreadType (const Char8 *szAppThreadType) |
| static ThreadManager * | the (void) |
| static BaseThread * | getAppThread (void) |
| static void | setNumAspects (UInt32 uiNumApects) |
| static UInt32 | getNumAspects (void) |
Protected Member Functions | |
| void | removeThread (BaseThread *pThread) |
| void | removeBarrier (Barrier *pBarrier) |
| void | removeLock (Lock *pLock) |
| void | removeLockPool (LockPool *pLockPool) |
| UInt32 | registerThreadType (MPThreadType *pType) |
| UInt32 | registerBarrierType (MPBarrierType *pType) |
| UInt32 | registerLockType (MPLockType *pType) |
| UInt32 | registerLockPoolType (MPLockPoolType *pType) |
| bool | init (void) |
| bool | shutdown (void) |
Constructors | |
| * | ThreadManager (void) |
Destructor | |
| *virtual | ~ThreadManager (void) |
Static Protected Member Functions | |
| static bool | initialize (void) |
| static bool | terminate (void) |
Private Member Functions | |
| ThreadManager (const ThreadManager &source) | |
| prohibit default function (move to 'public' if needed) | |
| void | operator= (const ThreadManager &source) |
| prohibit default function (move to 'public' if needed) | |
Static Private Attributes | |
Class Variable | |
| *static ThreadManager * | _pThreadManager = NULL |
| static BaseThread * | _pAppThread = NULL |
| static bool | _bShutdownInProgress = false |
| static UInt32 | _uiNumAspects = OSG_NUM_ASPECTS |
Definition at line 166 of file OSGThreadManager.h.
|
|
Definition at line 177 of file OSGThreadManager.h. |
|
|
Definition at line 178 of file OSGThreadManager.h. |
|
|
Definition at line 179 of file OSGThreadManager.h. |
|
|
Definition at line 421 of file OSGThreadManager.cpp. Referenced by the(). 00421 : 00422 _sThreadStore (), 00423 _sBarrierStore (), 00424 _sLockStore (), 00425 _sLockPoolStore(), 00426 00427 _storePLock (NULL) 00428 { 00429 #if defined(OSG_USE_SPROC) 00430 _pArena = NULL; 00431 #endif 00432 }
|
|
|
Definition at line 436 of file OSGThreadManager.cpp.
|
|
|
|
|
|
Definition at line 66 of file OSGThreadManager.cpp. References _szAppThreadType, and osg::stringDup(). Referenced by osg::Thread::initThreading(). 00067 { 00068 stringDup(szAppThreadType, _szAppThreadType); 00069 }
|
|
|
|
Definition at line 81 of file OSGThreadManager.cpp. References _pAppThread. Referenced by osg::BaseThread::~BaseThread(). 00082 { 00083 return _pAppThread; 00084 }
|
|
|
Definition at line 87 of file OSGThreadManager.cpp. References _uiNumAspects. 00088 { 00089 #if defined(OSG_RUNTIME_NUM_ASPECTS) 00090 if(_bNumAspectSet == false && uiNumAspects > 1) 00091 { 00092 #if defined(OSG_ASPECT_USE_PTHREADSELF) || \ 00093 defined(OSG_ASPECT_USE_CUSTOMSELF) 00094 UInt32 i; 00095 UInt16 *pAspect = new UInt16[uiNumAspects]; 00096 00097 for(i = 0; i < _uiNumAspects; i++) 00098 pAspect[i] = Thread::_pAspects[i]; 00099 00100 for(i = _uiNumAspects; i < uiNumAspects; i++) 00101 Thread::_pAspects[i] = 0; 00102 00103 delete [] Thread::_pAspects; 00104 00105 Thread::_pAspectsA = pAspect; 00106 #endif 00107 _uiNumAspects = uiNumAspects; 00108 _bNumAspectSet = true; 00109 } 00110 #endif 00111 }
|
|
|
Definition at line 114 of file OSGThreadManager.cpp. References _uiNumAspects. Referenced by osg::ChangeList::applyTo(), osg::QSceneGraphView::createChildWidgets(), osg::FieldContainerPtrBase::deleteContainers(), osg::QSceneGraphView::doSetRoot(), osg::FieldContainer::newPtr(), osg::QSceneGraphView::onRawAddressEntered(), osg::QSceneGraphView::onUpdateClicked(), osg::QSceneGraphView::QSceneGraphView(), and osg::PThreadBase::runFunction(). 00115 { 00116 return _uiNumAspects; 00117 }
|
|
||||||||||||
|
Definition at line 121 of file OSGThreadManager.cpp. References _sThreadStore, _storePLock, osg::Lock::aquire(), and osg::Lock::release(). Referenced by osg::ExternalThread::get(), osg::Thread::get(), osg::BaseThread::get(), init(), and osg::ProxyGroup::startLoading(). 00123 { 00124 BaseThread *returnValue = NULL; 00125 00126 _storePLock->aquire(); 00127 00128 returnValue = _sThreadStore.getMPField(szName, szTypeName); 00129 00130 _storePLock->release(); 00131 00132 return returnValue; 00133 }
|
|
||||||||||||
|
Definition at line 135 of file OSGThreadManager.cpp. References _sBarrierStore, _storePLock, osg::Lock::aquire(), osg::MPFieldStore< MPFieldT >::getMPField(), and osg::Lock::release(). Referenced by osg::Barrier::get(). 00137 { 00138 Barrier *returnValue = NULL; 00139 00140 _storePLock->aquire(); 00141 00142 returnValue = _sBarrierStore.getMPField(szName, szTypeName); 00143 00144 _storePLock->release(); 00145 00146 return returnValue; 00147 }
|
|
||||||||||||
|
Definition at line 149 of file OSGThreadManager.cpp. References _sLockStore, _storePLock, osg::Lock::aquire(), osg::MPFieldStore< MPFieldT >::getMPField(), and osg::Lock::release(). Referenced by osg::Window::GLObject::decRefCounter(), osg::Lock::get(), osg::Window::GLObject::incRefCounter(), osg::FieldContainerFactory::initialize(), and osg::Window::staticAcquire(). 00151 { 00152 Lock *returnValue = NULL; 00153 00154 _storePLock->aquire(); 00155 00156 returnValue = _sLockStore.getMPField(szName, szTypeName); 00157 00158 _storePLock->release(); 00159 00160 return returnValue; 00161 }
|
|
||||||||||||
|
Definition at line 163 of file OSGThreadManager.cpp. References _sLockPoolStore, _storePLock, osg::Lock::aquire(), osg::MPFieldStore< MPFieldT >::getMPField(), and osg::Lock::release(). Referenced by osg::LockPool::get(), and osg::FieldContainerPtrBase::initialize(). 00165 { 00166 LockPool *returnValue = NULL; 00167 00168 _storePLock->aquire(); 00169 00170 returnValue = _sLockPoolStore.getMPField(szName, szTypeName); 00171 00172 _storePLock->release(); 00173 00174 return returnValue; 00175 }
|
|
|
Definition at line 177 of file OSGThreadManager.cpp. References _sThreadStore, _storePLock, osg::Lock::aquire(), and osg::Lock::release(). Referenced by osg::ExternalThread::find(), osg::Thread::find(), and osg::BaseThread::find(). 00178 { 00179 BaseThread *returnValue = NULL; 00180 00181 _storePLock->aquire(); 00182 00183 returnValue = _sThreadStore.findMPField(szName); 00184 00185 _storePLock->release(); 00186 00187 return returnValue; 00188 }
|
|
|
Definition at line 190 of file OSGThreadManager.cpp. References _sBarrierStore, _storePLock, osg::Lock::aquire(), osg::MPFieldStore< MPFieldT >::findMPField(), and osg::Lock::release(). Referenced by osg::Barrier::find(). 00191 { 00192 Barrier *returnValue = NULL; 00193 00194 _storePLock->aquire(); 00195 00196 returnValue = _sBarrierStore.findMPField(szName); 00197 00198 _storePLock->release(); 00199 00200 return returnValue; 00201 }
|
|
|
Definition at line 203 of file OSGThreadManager.cpp. References _sLockStore, _storePLock, osg::Lock::aquire(), osg::MPFieldStore< MPFieldT >::findMPField(), and osg::Lock::release(). Referenced by osg::Lock::find(). 00204 { 00205 Lock *returnValue = NULL; 00206 00207 _storePLock->aquire(); 00208 00209 returnValue = _sLockStore.findMPField(szName); 00210 00211 _storePLock->release(); 00212 00213 return returnValue; 00214 }
|
|
|
Definition at line 216 of file OSGThreadManager.cpp. References _sLockPoolStore, _storePLock, osg::Lock::aquire(), osg::MPFieldStore< MPFieldT >::findMPField(), and osg::Lock::release(). Referenced by osg::LockPool::find(). 00217 { 00218 LockPool *returnValue = NULL; 00219 00220 _storePLock->aquire(); 00221 00222 returnValue = _sLockPoolStore.findMPField(szName); 00223 00224 _storePLock->release(); 00225 00226 return returnValue; 00227 }
|
|
|
Definition at line 240 of file OSGThreadManager.cpp.
|
|
|
Definition at line 245 of file OSGThreadManager.cpp. References shutdown(), and the().
|
|
|
Definition at line 250 of file OSGThreadManager.cpp. References _bShutdownInProgress, _sThreadStore, _storePLock, osg::Lock::aquire(), and osg::Lock::release(). Referenced by osg::BaseThread::~BaseThread(). 00251 { 00252 if(_bShutdownInProgress == true) 00253 return; 00254 00255 _storePLock->aquire(); 00256 00257 _sThreadStore.removeMPField(pThread); 00258 00259 _storePLock->release(); 00260 }
|
|
|
Definition at line 262 of file OSGThreadManager.cpp. References _bShutdownInProgress, _sBarrierStore, _storePLock, osg::Lock::aquire(), osg::Lock::release(), and osg::MPFieldStore< MPFieldT >::removeMPField(). Referenced by osg::Barrier::~Barrier(). 00263 { 00264 if(_bShutdownInProgress == true) 00265 return; 00266 00267 _storePLock->aquire(); 00268 00269 _sBarrierStore.removeMPField(pBarrier); 00270 00271 _storePLock->release(); 00272 }
|
|
|
Definition at line 274 of file OSGThreadManager.cpp. References _bShutdownInProgress, _sLockStore, _storePLock, osg::Lock::aquire(), osg::Lock::release(), and osg::MPFieldStore< MPFieldT >::removeMPField(). Referenced by osg::Lock::~Lock(). 00275 { 00276 if(_bShutdownInProgress == true) 00277 return; 00278 00279 _storePLock->aquire(); 00280 00281 _sLockStore.removeMPField(pLock); 00282 00283 _storePLock->release(); 00284 }
|
|
|
Definition at line 286 of file OSGThreadManager.cpp. References _bShutdownInProgress, _sLockPoolStore, _storePLock, osg::Lock::aquire(), osg::Lock::release(), and osg::MPFieldStore< MPFieldT >::removeMPField(). Referenced by osg::LockPool::~LockPool(). 00287 { 00288 if(_bShutdownInProgress == true) 00289 return; 00290 00291 _storePLock->aquire(); 00292 00293 _sLockPoolStore.removeMPField(pLockPool); 00294 00295 _storePLock->release(); 00296 }
|
|
|
Definition at line 298 of file OSGThreadManager.cpp. References _sThreadStore. Referenced by osg::MPThreadType::MPThreadType(). 00299 { 00300 return _sThreadStore.registerMPType(pType); 00301 }
|
|
|
Definition at line 303 of file OSGThreadManager.cpp. References _sBarrierStore, and osg::MPFieldStore< MPFieldT >::registerMPType(). Referenced by osg::MPBarrierType::MPBarrierType(). 00304 { 00305 return _sBarrierStore.registerMPType(pType); 00306 }
|
|
|
Definition at line 308 of file OSGThreadManager.cpp. References _sLockStore, and osg::MPFieldStore< MPFieldT >::registerMPType(). Referenced by osg::MPLockType::MPLockType(). 00309 { 00310 return _sLockStore.registerMPType(pType); 00311 }
|
|
|
Definition at line 313 of file OSGThreadManager.cpp. References _sLockPoolStore, and osg::MPFieldStore< MPFieldT >::registerMPType(). Referenced by osg::MPLockPoolType::MPLockPoolType(). 00314 { 00315 return _sLockPoolStore.registerMPType(pType); 00316 }
|
|
|
Definition at line 323 of file OSGThreadManager.cpp. References _pAppThread, _sLockStore, _storePLock, _szAppThreadType, FDEBUG, FFASSERT, FINFO, osg::Barrier::getClassType(), osg::BaseThread::getClassType(), osg::Lock::getClassType(), osg::MPFieldStore< MPFieldT >::getMPField(), getThread(), osg::BasePThreadBase::init(), SFATAL, and SINFO. Referenced by initialize(). 00324 { 00325 bool returnValue = true; 00326 00327 FDEBUG(("OSGThreadManager init\n")) 00328 00329 #if defined(OSG_USE_SPROC) 00330 usconfig(CONF_AUTOGROW, 1); 00331 usconfig(CONF_INITUSERS, 20); 00332 usconfig(CONF_INITSIZE, 10 * 1048576); 00333 usconfig(CONF_CHMOD, 0666); 00334 00335 _pArena = usinit("/dev/zero"); 00336 00337 if(_pArena == NULL) 00338 { 00339 SFATAL << "OSGTM : could not initialize arena " << errno << std::endl; 00340 returnValue = false; 00341 } 00342 else 00343 { 00344 SINFO << "OSGTM : got arena " << _pArena << std::endl; 00345 } 00346 #endif 00347 00348 #ifdef darwin 00349 Lock ::getClassType(); 00350 BaseThread::getClassType(); 00351 Barrier ::getClassType(); 00352 #endif 00353 00354 _storePLock = _sLockStore.getMPField("OSGTMStoreLock", "OSGLock"); 00355 00356 if(_storePLock == NULL) 00357 { 00358 SFATAL << "OSGTM : could not get table lock" << std::endl; 00359 00360 returnValue = false; 00361 } 00362 else 00363 { 00364 SINFO << "OSGTM : got table lock " << _storePLock << std::endl; 00365 } 00366 00367 if(_szAppThreadType == NULL) 00368 { 00369 FINFO(("OSGTM : create -OSGBaseThread- app thread\n")) 00370 00371 _pAppThread = getThread("OSGAppThread", "OSGBaseThread"); 00372 } 00373 else 00374 { 00375 FINFO(("OSGTM : create -%s- app thread\n", _szAppThreadType)) 00376 _pAppThread = getThread("OSGAppThread", _szAppThreadType); 00377 } 00378 00379 FFASSERT((_pAppThread != NULL), 1, 00380 ("OSGTM : could not get application thread \n");) 00381 00382 00383 FINFO(("OSGTM : got application thread %p\n", _pAppThread)) 00384 00385 _pAppThread->init(); 00386 00387 return returnValue; 00388 }
|
|
|
Definition at line 394 of file OSGThreadManager.cpp. References _bShutdownInProgress, _sBarrierStore, _sLockPoolStore, _sLockStore, _sThreadStore, osg::MPFieldStore< MPFieldT >::clear(), osg::PThreadBase::freeAspect(), osg::PThreadBase::freeChangeList(), and osg::BasePThreadBase::freeThread(). Referenced by terminate(). 00395 { 00396 _bShutdownInProgress = true; 00397 00398 _sThreadStore.clear(); 00399 _sBarrierStore.clear(); 00400 _sLockStore.clear(); 00401 _sLockPoolStore.clear(); 00402 00403 #ifdef CHECK 00404 #if defined (OSG_ASPECT_USE_LOCALSTORAGE) 00405 Thread::freeAspect(); 00406 Thread::freeThread(); 00407 Thread::freeChangeList(); 00408 #endif 00409 #endif 00410 00411 #if defined(OSG_USE_SPROC) 00412 if(_pArena != NULL) 00413 usdetach(_pArena); 00414 #endif 00415 00416 return true; 00417 }
|
|
|
|
|
|
Definition at line 267 of file OSGThreadManager.h. |
|
|
Definition at line 268 of file OSGThreadManager.h. |
|
|
Definition at line 269 of file OSGThreadManager.h. |
|
|
Definition at line 271 of file OSGThreadManager.h. |
|
|
Definition at line 272 of file OSGThreadManager.h. |
|
|
Definition at line 273 of file OSGThreadManager.h. |
|
|
Definition at line 274 of file OSGThreadManager.h. |
|
||||||||||||
|
Definition at line 181 of file OSGBaseFunctions.cpp. 00182 { 00183 // without it floats could be written as "1,456" ... 00184 setlocale(LC_NUMERIC, "English"); 00185 00186 UInt32 i; 00187 bool returnValue = true; 00188 00189 returnValue = SharedObjectHandler::the()->initialize(); 00190 00191 if(osgPreloadSharedObject != NULL) 00192 { 00193 for(UInt32 i = 0; i < osgPreloadSharedObject->size(); ++i) 00194 { 00195 SharedObjectHandler::the()->getOSGSharedObject( 00196 (*osgPreloadSharedObject)[i].c_str()); 00197 } 00198 } 00199 00200 char *szEnvLibs = getenv("OSG_LOAD_LIBS"); 00201 00202 if(szEnvLibs != NULL) 00203 { 00204 std::string tmpString(szEnvLibs); 00205 string_token_iterator libIt(tmpString, ":"); 00206 00207 string_token_iterator libEnd; 00208 00209 while(libIt != libEnd) 00210 { 00211 SharedObjectHandler::the()->getOSGSharedObject( 00212 (*libIt).c_str()); 00213 00214 ++libIt; 00215 } 00216 } 00217 00218 const char *szEnvPlugins = getenv("OSG_PLUGIN_PATH"); 00219 const char *szEnvPluginPattern = getenv("OSG_PLUGIN_PATTERN"); 00220 00221 if(szEnvPlugins != NULL) 00222 { 00223 if(szEnvPluginPattern == NULL) 00224 { 00225 szEnvPluginPattern = PluginPattern; 00226 } 00227 00228 FINFO(("Get Plugins %s from %s\n", 00229 szEnvPluginPattern, 00230 szEnvPlugins)); 00231 00232 std::vector<Char8 *> *pPlugins = 00233 Directory::getEntries(szEnvPlugins, szEnvPluginPattern); 00234 00235 if(pPlugins != NULL) 00236 { 00237 std::string szPluginName; 00238 00239 for(UInt32 i = 0; i < pPlugins->size(); ++i) 00240 { 00241 if((*pPlugins)[i][0] == '.') 00242 { 00243 if((*pPlugins)[i][1] == '\0') 00244 { 00245 continue; 00246 } 00247 else if((*pPlugins)[i][1] == '.' && 00248 (*pPlugins)[i][2] == '\0') 00249 { 00250 continue; 00251 } 00252 } 00253 00254 szPluginName.assign(szEnvPlugins); 00255 szPluginName += '/'; 00256 szPluginName += (*pPlugins)[i]; 00257 00258 SharedObjectHandler::the()->getSharedObject( 00259 szPluginName.c_str()); 00260 } 00261 } 00262 00263 delete pPlugins; 00264 } 00265 00266 SharedObjectHandler::the()->dump(); 00267 00268 if(returnValue == false) 00269 return returnValue; 00270 00271 if(osgPreMPInitFunctions != NULL) 00272 { 00273 for(i = 0; i < osgPreMPInitFunctions->size(); i++) 00274 { 00275 returnValue &= (*osgPreMPInitFunctions)[i](); 00276 00277 if(returnValue == false) 00278 break; 00279 } 00280 00281 osgPreMPInitFunctions->clear(); 00282 } 00283 00284 if(returnValue == false) 00285 return returnValue; 00286 00287 returnValue &= ThreadManager::initialize(); 00288 00289 if(returnValue == false) 00290 return returnValue; 00291 00292 if(osgInitFunctions != NULL) 00293 { 00294 for(i = 0; i < osgInitFunctions->size(); i++) 00295 { 00296 returnValue &= (*osgInitFunctions)[i](); 00297 00298 if(returnValue == false) 00299 break; 00300 } 00301 00302 osgInitFunctions->clear(); 00303 } 00304 00305 if(returnValue == false) 00306 return returnValue; 00307 00308 #ifdef OSG_GV_BETA 00309 returnValue &= FactoryController::the()->initialize(); 00310 #endif 00311 00312 GlobalSystemState = Running; 00313 00314 atexit(osgExitWrapper); 00315 00316 return returnValue; 00317 }
|
|
|
Definition at line 322 of file OSGBaseFunctions.cpp. 00323 { 00324 bool returnValue = true; 00325 00326 if(GlobalSystemState != Running) 00327 return true; 00328 00329 GlobalSystemState = Shutdown; 00330 00331 #ifdef OSG_GV_BETA 00332 returnValue &= FactoryController::the()->terminate(); 00333 #endif 00334 00335 if(osgSystemExitFunctions != NULL) 00336 { 00337 for(Int32 i = osgSystemExitFunctions->size() - 1; i >= 0; i--) 00338 { 00339 returnValue &= (*osgSystemExitFunctions)[i](); 00340 00341 if(returnValue == false) 00342 break; 00343 } 00344 } 00345 00346 returnValue &= ThreadManager::terminate(); 00347 00348 if(osgPostMPExitFunctions != NULL) 00349 { 00350 for(Int32 i = osgPostMPExitFunctions->size() - 1; i >= 0; i--) 00351 { 00352 returnValue &= (*osgPostMPExitFunctions)[i](); 00353 00354 if(returnValue == false) 00355 break; 00356 } 00357 } 00358 00359 return returnValue; 00360 }
|
|
|
Definition at line 176 of file OSGThreadManager.h. |
|
|
Definition at line 266 of file OSGThreadManager.h. |
|
|
Definition at line 51 of file OSGThreadManager.cpp. Referenced by the(). |
|
|
Definition at line 52 of file OSGThreadManager.cpp. Referenced by getAppThread(), and init(). |
|