NLMISC::CTDS Class Reference

#include <tds.h>


Detailed Description

Thread dependant storage class

This class provides a thread specific (void*). It is initialized at NULL.

Author:
Cyril 'Hulud' Corvazier

Nevrax France

Date:
2002

Definition at line 46 of file tds.h.

Public Member Functions

 CTDS ()
 Constructor. The pointer is initialized with NULL.

void * getPointer () const
 Get the thread specific pointer.

void setPointer (void *pointer)
 Set the thread specific pointer.

 ~CTDS ()
 Destructor.


Private Attributes

pthread_key_t _Key


Constructor & Destructor Documentation

NLMISC::CTDS::CTDS  ) 
 

Constructor. The pointer is initialized with NULL.

Definition at line 41 of file tds.cpp.

00042 {
00043         /* Please no assert in the constructor because it is called by the NeL memory allocator constructor */
00044 #ifdef NL_OS_WINDOWS
00045         _Handle = TlsAlloc ();
00046         TlsSetValue (_Handle, NULL);
00047 #else // NL_OS_WINDOWS
00048         _Key = pthread_key_create (&_Key, NULL);
00049         pthread_setspecific(_Key, NULL);
00050 #endif // NL_OS_WINDOWS
00051 }

NLMISC::CTDS::~CTDS  ) 
 

Destructor.

Definition at line 55 of file tds.cpp.

References nlverify.

00056 {
00057 #ifdef NL_OS_WINDOWS
00058         nlverify (TlsFree (_Handle));
00059 #else // NL_OS_WINDOWS
00060         nlverify (pthread_key_delete (_Key) == 0);
00061 #endif // NL_OS_WINDOWS
00062 }


Member Function Documentation

void * NLMISC::CTDS::getPointer  )  const
 

Get the thread specific pointer.

Definition at line 66 of file tds.cpp.

Referenced by NLMISC::CHeapAllocator::debugPopCategoryString(), NLMISC::CHeapAllocator::debugPushCategoryString(), and NLMISC::CBigFile::CThreadFileArray::get().

00067 {
00068 #ifdef NL_OS_WINDOWS
00069         return TlsGetValue (_Handle);
00070 #else // NL_OS_WINDOWS
00071         return pthread_getspecific (_Key);
00072 #endif // NL_OS_WINDOWS
00073 }

void NLMISC::CTDS::setPointer void *  pointer  ) 
 

Set the thread specific pointer.

Definition at line 77 of file tds.cpp.

References nlverify, and pointer.

Referenced by NLMISC::CHeapAllocator::debugPopCategoryString(), NLMISC::CHeapAllocator::debugPushCategoryString(), and NLMISC::CBigFile::CThreadFileArray::get().

00078 {
00079 #ifdef NL_OS_WINDOWS
00080         nlverify (TlsSetValue (_Handle, pointer));
00081 #else // NL_OS_WINDOWS
00082         nlverify (pthread_setspecific (_Key, pointer) == 0);
00083 #endif // NL_OS_WINDOWS
00084 }


Field Documentation

pthread_key_t NLMISC::CTDS::_Key [private]
 

Definition at line 66 of file tds.h.


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 13:37:27 2004 for NeL by doxygen 1.3.6