#include <PsnNew.h>
Public Methods | |
| HeapStackTop (PsnMemoryManager *newTop) | |
| constructor install newTop as the new default memory allocator | |
| virtual | ~HeapStackTop () |
| destructor reinstall _oldMemoryManager as the default memory allocator | |
| void * | operator new (size_t) |
| redefine allocation for fast allocation - deallocation cycles | |
| void | operator delete (void *, size_t) |
Static Public Methods | |
| pthread_key_t | initialiseGlobalMemoryManagerKey () |
| a function to enble correct initialisation of keys | |
| pthread_key_t | initialiseFreedKey () |
| a function to enble correct initialisation of keys | |
| PsnSystemMemoryManager * | getSystemMemoryManager () |
| a function to get to the system memory manager wich is wrapped by the PsnSharedMemoryManager class | |
Static Public Attributes | |
| pthread_key_t | globalMemoryManagerKey = HeapStackTop::initialiseGlobalMemoryManagerKey () |
| A key for a thread to access it's current memory manager. | |
Protected Attributes | |
| void * | _oldMemoryManager |
| the old memoryManager replaced during creation of this HeapStackTop | |
Static Protected Attributes | |
| pthread_key_t | freedKey = HeapStackTop::initialiseFreedKey () |
| A key for a thread to access it's last freed memory area for an object of HeapStackTop type. | |
Friends | |
| class | PsController |
| declare the controler as a friend so that freedKey can be properly destroyed | |
Definition at line 30 of file PsnNew.h.
|
|
constructor install newTop as the new default memory allocator
Definition at line 98 of file PsnNew.cxx. References _oldMemoryManager, globalMemoryManagerKey, and initialiseGlobalMemoryManagerKey().
00098 {
00099 static pthread_key_t bidon = HeapStackTop::initialiseGlobalMemoryManagerKey () ;
00100 #ifdef _DEBUGMEMORYMANAGEMENT
00101 cerr<<"HeapStackTop::HeapStackTop"<<endl;
00102 #endif
00103 _oldMemoryManager = pthread_getspecific( globalMemoryManagerKey ) ;
00104 pthread_setspecific ( globalMemoryManagerKey , newTop );
00105 }
|
|
|
destructor reinstall _oldMemoryManager as the default memory allocator
Definition at line 109 of file PsnNew.cxx. References _oldMemoryManager, globalMemoryManagerKey, and initialiseGlobalMemoryManagerKey().
00109 {
00110 static pthread_key_t bidon = HeapStackTop::initialiseGlobalMemoryManagerKey () ;
00111 #ifdef _DEBUGMEMORYMANAGEMENT
00112 cerr<<"HeapStackTop::~HeapStackTop"<<endl;
00113 #endif
00114 pthread_setspecific ( globalMemoryManagerKey , _oldMemoryManager );
00115 }
|
|
|
a function to get to the system memory manager wich is wrapped by the PsnSharedMemoryManager class
Definition at line 24 of file PsnNew.cxx. Referenced by PsnMultiThreadedScheduler::_threadContainer(), PsnMultiThreadedBenchmarkingScheduler::_threadContainer(), PsOutput< Type >::getDateOfLastExactValue(), PsOutput< Type >::getLastExactValue(), initialiseGlobalMemoryManagerKey(), PsOutput< Type >::localGet(), PsOutput< Type >::localInsert(), PsnMemoryElementDescriptor::operator new(), PsMultiThreadedPvmController::run(), PsMultiThreadedController::run(), and PsnMemoryManager::whichMemoryManager().
00025 {
00026 // using new causes an infinite loop, as new needs getSystmeMemoryManager
00027 //
00028 static PsnSystemMemoryManager toto ;
00029 return & toto ;
00030 }
|
|
|
a function to enble correct initialisation of keys
Definition at line 52 of file PsnNew.cxx. References freedKey. Referenced by operator delete(), and operator new().
00053 {
00054 static bool done = false ;
00055 if ( ! done )
00056 {
00057 pthread_key_t res ;
00058 pthread_key_create(&res, NULL) ;
00059 pthread_setspecific ( res , NULL );
00060 done = true ;
00061 freedKey =res ;
00062 return res ;
00063 }
00064 else
00065 {
00066 return freedKey ;
00067 }
00068 }
|
|
|
a function to enble correct initialisation of keys
Definition at line 32 of file PsnNew.cxx. References getSystemMemoryManager(), and globalMemoryManagerKey. Referenced by HeapStackTop(), operator new(), and ~HeapStackTop().
00033 {
00034 static bool done = false ;
00035 if ( ! done )
00036 {
00037 pthread_key_t res ;
00038 pthread_key_create(&res, NULL) ;
00039 pthread_setspecific ( res , getSystemMemoryManager() );
00040 done = true ;
00041 globalMemoryManagerKey = res ;
00042 return res ;
00043 }
00044 else
00045 {
00046 return globalMemoryManagerKey ;
00047 }
00048 }
|
|
||||||||||||
|
Definition at line 87 of file PsnNew.cxx. References freedKey, and initialiseFreedKey().
00087 {
00088 static pthread_key_t bidon = initialiseFreedKey () ;
00089 void * freed = pthread_getspecific(freedKey) ;
00090 if (freed!=NULL) {
00091 ::operator delete (freed);
00092 }
00093 pthread_setspecific(freedKey, addr);
00094 }
|
|
|
redefine allocation for fast allocation - deallocation cycles
Definition at line 75 of file PsnNew.cxx. References freedKey, initialiseFreedKey(), and operator new().
00075 {
00076 static pthread_key_t bidon = initialiseFreedKey () ;
00077 void * freed = pthread_getspecific(freedKey) ;
00078
00079 if (freed!=NULL) {
00080 return freed;
00081 }
00082 else {
00083 return ::operator new(size);
00084 }
00085 }
|
|
|
declare the controler as a friend so that freedKey can be properly destroyed
|
|
|
the old memoryManager replaced during creation of this HeapStackTop
Definition at line 63 of file PsnNew.h. Referenced by HeapStackTop(), and ~HeapStackTop(). |
|
|
A key for a thread to access it's last freed memory area for an object of HeapStackTop type.
Definition at line 71 of file PsnNew.cxx. Referenced by initialiseFreedKey(), operator delete(), and operator new(). |
|
|
A key for a thread to access it's current memory manager. Use should be implicit, through creation and deletion of heapStackTop objects Definition at line 70 of file PsnNew.cxx. Referenced by HeapStackTop(), initialiseGlobalMemoryManagerKey(), PsnRelaxedMemoryManager::mLatencyMalloc(), PsnRelaxedMemoryManager::mmallocForOnce(), operator delete(), PsnMemoryElementDescriptor::operator delete(), operator new(), PsnMomeArray< T >::PsnMomeArray(), ~HeapStackTop(), and PsnMemoryManager::~PsnMemoryManager(). |
| Documentation generated on Mon Nov 25 15:26:02 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |