NLMEMORY::CMemoryTDS Class Reference

#include <memory_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 44 of file memory_tds.h.

Public Member Functions

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

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

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

 ~CMemoryTDS ()
 Destructor.


Private Attributes

pthread_key_t _Key


Constructor & Destructor Documentation

NLMEMORY::CMemoryTDS::CMemoryTDS  ) 
 

Constructor. The pointer is initialized with NULL.

Definition at line 43 of file memory_tds.cpp.

References _Key.

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

NLMEMORY::CMemoryTDS::~CMemoryTDS  ) 
 

Destructor.

Definition at line 57 of file memory_tds.cpp.

References _Key.

00058 {
00059 #ifdef NL_OS_WINDOWS
00060         TlsFree (_Handle);
00061 #else // NL_OS_WINDOWS
00062         pthread_key_delete (_Key);
00063 #endif // NL_OS_WINDOWS
00064 }


Member Function Documentation

void * NLMEMORY::CMemoryTDS::getPointer  )  const
 

Get the thread specific pointer.

Definition at line 68 of file memory_tds.cpp.

References _Key.

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

void NLMEMORY::CMemoryTDS::setPointer void *  pointer  ) 
 

Set the thread specific pointer.

Definition at line 79 of file memory_tds.cpp.

References _Key, and pointer.

00080 {
00081 #ifdef NL_OS_WINDOWS
00082         TlsSetValue (_Handle, pointer);
00083 #else // NL_OS_WINDOWS
00084         pthread_setspecific (_Key, pointer);
00085 #endif // NL_OS_WINDOWS
00086 }


Field Documentation

pthread_key_t NLMEMORY::CMemoryTDS::_Key [private]
 

Definition at line 64 of file memory_tds.h.

Referenced by CMemoryTDS(), getPointer(), setPointer(), and ~CMemoryTDS().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 12:56:53 2004 for NeL by doxygen 1.3.6