osg::LockPool Class Reference
[Multithreading]

#include <OSGLock.h>

Inheritance diagram for osg::LockPool:

osg::LockCommonBase osg::MPBase osg::MemoryObject

List of all members.

Public Types

typedef MPLockPoolType Type

Public Member Functions

Lock


void aquire (void *keyP)
void release (void *keyP)
bool request (void *keyP)
Get


virtual MPTypegetType (void)
virtual const MPTypegetType (void) const
UInt32 getTypeId (void)
const Char8getCName (void) const
Reference Counting


void addRef (void)
void subRef (void)
Int32 getRefCount (void)

Static Public Member Functions

Get


static LockPoolget (const Char8 *szName)
static LockPoolfind (const Char8 *szName)
static LockPoolcreate (void)
Class Get


static const MPTypegetStaticType (void)
static UInt32 getStaticTypeId (void)

Protected Types

typedef LockCommonBase Inherited

Protected Member Functions

Constructor


 LockPool (const Char8 *szName, UInt32 uiId)
Destructor


virtual ~LockPool (void)
Construction


bool init (void)
Destruction


void shutdown (void)

Static Protected Member Functions

Create


static LockPoolcreate (const Char8 *szName, UInt32 uiId)

Protected Attributes

Lock _pLocks [uiLockPoolSize]
UInt32 _uiLockId
Class Specific


Char8_szName

Static Protected Attributes

static MPLockPoolType _type

Private Member Functions

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

Friends

class MPFieldStore< LockPool >


Detailed Description

Definition at line 463 of file OSGLock.h.


Member Typedef Documentation

Definition at line 469 of file OSGLock.h.

Reimplemented from osg::LockCommonBase.

Definition at line 493 of file OSGLock.h.


Constructor & Destructor Documentation

LockPool::LockPool ( const Char8 szName,
UInt32  uiId 
) [protected]

Definition at line 572 of file OSGLock.cpp.

Referenced by create().

00573                                          :
00574     Inherited(szName, uiId)
00575 {
00576 }

LockPool::~LockPool ( void   )  [protected, virtual]

Definition at line 580 of file OSGLock.cpp.

References osg::ThreadManager::removeLockPool(), shutdown(), and osg::ThreadManager::the().

00581 {
00582     ThreadManager::the()->removeLockPool(this);
00583 
00584     shutdown();
00585 }

osg::LockPool::LockPool ( const LockPool source  )  [private]


Member Function Documentation

LockPool * LockPool::get ( const Char8 szName  )  [static]

Definition at line 513 of file OSGLock.cpp.

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

Referenced by create().

00514 {
00515     return ThreadManager::the()->getLockPool(szName, "OSGLockPool");
00516 }

LockPool * LockPool::find ( const Char8 szName  )  [static]

Definition at line 518 of file OSGLock.cpp.

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

00519 {
00520     return ThreadManager::the()->findLockPool(szName);
00521 }

LockPool * LockPool::create ( void   )  [static]

Definition at line 523 of file OSGLock.cpp.

References get().

00524 {
00525     return LockPool::get(NULL);
00526 }

void LockPool::aquire ( void *  keyP  ) 

Definition at line 534 of file OSGLock.cpp.

References _pLocks, and osg::uiLockPoolMask.

Referenced by osg::FieldContainerPtrBase::addRef(), and osg::FieldContainerPtrBase::subRef().

00535 {
00536     _pLocks[(UInt64(keyP) & uiLockPoolMask) >> 7].aquire();
00537 }

void LockPool::release ( void *  keyP  ) 

Definition at line 539 of file OSGLock.cpp.

References _pLocks, and osg::uiLockPoolMask.

Referenced by osg::FieldContainerPtrBase::addRef(), and osg::FieldContainerPtrBase::subRef().

00540 {
00541     _pLocks[(UInt64(keyP) & uiLockPoolMask) >> 7].release();
00542 }

bool LockPool::request ( void *  keyP  ) 

Definition at line 544 of file OSGLock.cpp.

References _pLocks, and osg::uiLockPoolMask.

00545 {
00546     return _pLocks[(UInt64(keyP) & uiLockPoolMask) >> 7].request();
00547 }

LockPool * LockPool::create ( const Char8 szName,
UInt32  uiId 
) [static, protected]

Definition at line 555 of file OSGLock.cpp.

References init(), and LockPool().

00556 {
00557     LockPool *returnValue = NULL;
00558 
00559     returnValue = new LockPool(szName, uiId);
00560 
00561     if(returnValue->init() == false)
00562     {
00563         delete returnValue;
00564         returnValue = NULL;
00565     }
00566 
00567     return returnValue;
00568 }

bool LockPool::init ( void   )  [protected]

Definition at line 589 of file OSGLock.cpp.

References _pLocks, osg::MPBase::_szName, osg::PThreadLockBase::init(), osg::stringDup(), and osg::uiLockPoolSize.

Referenced by create().

00590 {
00591     bool   returnValue = true;
00592     Char8 *pTmp;
00593 
00594     pTmp = new Char8[strlen(_szName) + 6];
00595 
00596     for(UInt32 i = 0; i < uiLockPoolSize; i++)
00597     {
00598 #ifdef OSG_DEBUG_LOCK_STAT
00599         _pLockStats[i] = 0;
00600 #endif
00601         sprintf(pTmp, "%s%u\n", _szName, i);
00602 
00603         stringDup(pTmp, _pLocks[i]._szName);
00604 
00605         returnValue &= _pLocks[i].init();
00606     }
00607 
00608     delete [] pTmp;
00609 
00610     return returnValue;
00611 }

void LockPool::shutdown ( void   )  [protected]

Definition at line 615 of file OSGLock.cpp.

References _pLocks, osg::PThreadLockBase::shutdown(), and osg::uiLockPoolSize.

Referenced by ~LockPool().

00616 {
00617     for(UInt32 i = 0; i < uiLockPoolSize; i++)
00618     {
00619         _pLocks[i].shutdown();
00620     }
00621 }

void osg::LockPool::operator= ( const LockPool source  )  [private]

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]

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 MPFieldStore< LockPool > [friend]

Definition at line 542 of file OSGLock.h.


Member Data Documentation

MPLockPoolType LockPool::_type [static, protected]

Reimplemented from osg::MPBase.

Definition at line 495 of file OSGLock.h.

Definition at line 497 of file OSGLock.h.

Referenced by aquire(), init(), release(), request(), and shutdown().

UInt32 osg::LockCommonBase::_uiLockId [protected, inherited]

Definition at line 92 of file OSGLock.h.

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


The documentation for this class was generated from the following files:

Generated on Mon Mar 17 11:10:47 2008 for OpenSG by  doxygen 1.5.5