40#ifndef MAT_ALLOCATORMANAGER_HEADER
41#define MAT_ALLOCATORMANAGER_HEADER
64 throw std::runtime_error(
"Error in AllocatorManager: "
65 "attempt to re-initialize with different parameters.");
68 throw std::runtime_error(
"Error in AllocatorManager: bad input to init().");
78 typename std::list< Allocator<Treal>* >
::iterator it =
list.begin();
79 while(it !=
list.end()) {
80 if(!(*it)->isFull()) {
82 Treal* ptr = (*it)->alloc();
101 catch (
const std::bad_alloc &
e) {
104 std::cerr <<
"Error in AllocatorManager::alloc(): std::bad_alloc exception caught. Usage before error: list.size() = " <<
list.size()
110 std::cerr <<
"Error in AllocatorManager::alloc(): exception caught (but not std::bad_alloc!?!)." << std::endl;
112 throw std::runtime_error(
"Error in AllocatorManager::alloc(): exception caught (but not std::bad_alloc!?!).");
124 typename std::list< Allocator<Treal>* >
::iterator it =
list.begin();
125 while(it !=
list.end()) {
126 if((*it)->ownsPtr(ptr)) {
129 if((*it)->isEmpty()) {
150 typename std::list< Allocator<Treal>* >
::iterator it =
list.begin();
151 while(it !=
list.end()) {
155 std::stringstream
ss;
156 ss <<
"AllocatorManager statistics: ";
157 ss << std::setprecision(3)
160 <<
" list.size(): " <<
list.size()
173 std::cerr <<
"Error in AllocatorManager destructor: not empty." << std::endl;
177 typename std::list< Allocator<Treal>* >
::iterator it =
list.begin();
178 while(it !=
list.end()) {
183 std::list< Allocator<Treal>* >
list;
Code for Allocator class used for memory allocation/deallocation in matrix library.
Definition AllocatorManager.h:56
void init(size_t noOfRealsPerBuffer_, size_t noOfBuffers_)
Definition AllocatorManager.h:58
AllocatorManager()
Definition AllocatorManager.h:168
pthread_mutex_t mutex
Definition AllocatorManager.h:186
~AllocatorManager()
Definition AllocatorManager.h:171
size_t noOfBuffers
Definition AllocatorManager.h:185
static AllocatorManager & instance()
size_t peakListSize
Definition AllocatorManager.h:187
std::list< Allocator< Treal > * > list
Definition AllocatorManager.h:183
std::string getStatistics()
Definition AllocatorManager.h:141
void free(Treal *ptr)
Definition AllocatorManager.h:121
Treal * alloc(size_t n)
Definition AllocatorManager.h:73
size_t noOfRealsPerBuffer
Definition AllocatorManager.h:184
Definition Allocator.h:52
Definition allocate.cc:39
static Treal getMachineEpsilon()
Definition matInclude.h:147