NeoPZ
tpzautopointer.cpp
Go to the documentation of this file.
1 
6 #include "tpzautopointer.h"
7 
9 
10 #ifdef PROFILE_AP_MUTEXES
11  uint64_t ap_mutex_accesses[AP_MUTEX_ARRAY_SZ];
12 #endif
13 
14 /* Class to initialize the array. */
16 {
17 public:
19  {
20  for (int i=0; i< AP_MUTEX_ARRAY_SZ; i++) {
21  pthread_mutex_init(&(gAutoPointerMutexArray[i]),0);
22 #ifdef PROFILE_AP_MUTEXES
23  std::cout << "Inicializando autopointe mutex " << i << std:endl;
24  ap_mutex_accesses[i] = 0;
25 #endif
26  }
27  }
29  {
30  for (int i=0; i< AP_MUTEX_ARRAY_SZ; i++) {
31  pthread_mutex_destroy(&(gAutoPointerMutexArray[i]));
32 #ifdef PROFILE_AP_MUTEXES
33  std:cout << "Destruindo autopointer mutex " << i << std:endl;
34  printf("AutoPointer Mutex 0x%p accessed %lld times\n",
35  &(gAutoPointerMutexArray[i]), ap_mutex_accesses[i]);
36 #endif
37  }
38  }
39 
40 };
41 
43 
44 // template < class T>
45 // pthread_mutex_t TPZAutoPointer<T>::gAutoCounterMutex = PTHREAD_MUTEX_INITIALIZER;
46 
47 // pthread_mutex_t TPZAutoPointer<TPZSavable>::gAutoCounterMutex = PTHREAD_MUTEX_INITIALIZER;
48 
49 // template class TPZAutoPointer<TPZSavable>;
50 //gAutoPointerMutex = PTHREAD_MUTEX_INITIALIZER;
#define AP_MUTEX_ARRAY_SZ
Increment and Decrement actions are mutexed by this mutex.
AutoPointerMutexArrayInit tmp
pthread_mutex_t gAutoPointerMutexArray[AP_MUTEX_ARRAY_SZ]
Contains declaration of the TPZAutoPointer class which has Increment and Decrement actions are mutexe...