SbThreadLocalStorage Class Reference

VSG extension Thread Local Storage (TLS) class. More...

#include <Inventor/threads/SbThreadLocalStorage.h>

List of all members.

Static Public Member Functions

static void createStorage (size_t &classThreadId, const size_t byteSize, SoInitTLSClassCB *initFunc=NULL, SoExitTLSClassCB *exitFunc=NULL, const char *funcName=NULL)
static void deleteStorage (size_t &classThreadId, const char *funcName=NULL)
static bool isInitialized (const size_t classThreadId)
static void * getStorage (const size_t classThreadId)

Detailed Description

VSG extension Thread Local Storage (TLS) class.

This class allows to create thread local data storage. This allow to manage per thread static global variables in multithread mode.

Example on how to use the Thread Local Storage (TLS):

In this example we move static variables s_myStaticVar1 and s_myStaticVar2 of the class MyClass to Thread Local Storage,


SbThread, SbThreadAutoLock, SbThreadAutoReadLock, SbThreadAutoWriteLock, SbThreadBarrier, SbThreadRWMutex, SbThreadSignal

Member Function Documentation

static void SbThreadLocalStorage::createStorage ( size_t &  classThreadId,
const size_t  byteSize,
SoInitTLSClassCB initFunc = NULL,
SoExitTLSClassCB exitFunc = NULL,
const char *  funcName = NULL 
) [static]

Creates or updates the local storage for the current thread.

Requests that 'size' bytes of storage should be allocated for all threads for the calling class. Returns a unique classThreadId to be used by getStorage method to access the storage. Used by SB_THREAD_INIT_CLASS

static void SbThreadLocalStorage::deleteStorage ( size_t &  classThreadId,
const char *  funcName = NULL 
) [static]

Deletes the local storage for all threads.


static void* SbThreadLocalStorage::getStorage ( const size_t  classThreadId  )  [static]

Returns a pointer on the storage for the given classThreadId.

This storage is guaranteed to be local to the current thread. The size of the storage is defined by what was requested by createStorage, unless the pointer returned is NULL.

If the storage has not been created, then it will create it if possible.

static bool SbThreadLocalStorage::isInitialized ( const size_t  classThreadId  )  [static]

Returns true if a TLS storage has already been allocated for the given classThreadId.

The method is used in exitTLSClass() implementation to avoid calling getStorage() which will create the TLS if not found, which is useless as the purpose of exitTLSClass() is to delete associated resources. Used by SB_THREAD_IS_INITIALIZED macro.

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

Open Inventor Toolkit reference manual, generated on 28 Jun 2022
Copyright © Thermo Fisher Scientific All rights reserved.