Skip to content
Snippets Groups Projects
Commit 0bd96ee6 authored by Robert Klöfkorn's avatar Robert Klöfkorn
Browse files

remember who has locked free, and only set unlock if no one else has

locked.


git-svn-id: https://dune.mathematik.uni-freiburg.de/svn/alugrid/trunk@943 0d966ed9-3843-0410-af09-ebfb50bd7c74
parent a0379b9c
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,7 @@ ParallelGridMover :: ParallelGridMover (BuilderIF & b, bool init) : MacroGridBui
{
// lock MyAlloc so that objects are not freed
// because we want to reuse them
MyAlloc :: lockFree () ;
MyAlloc :: lockFree ((void *) this) ;
if(init) initialize();
}
......@@ -74,7 +74,7 @@ inline ParallelGridMover :: ~ParallelGridMover () {
assert(_initialized);
// unlock MyAlloc so that objects can be freed again
MyAlloc :: unlockFree () ;
MyAlloc :: unlockFree ((void *) this) ;
return ;
}
......
......@@ -65,15 +65,23 @@ struct AllocEntry {
// map holding AllocEntries for sizes
static map < size_t, AllocEntry, less < size_t > > * freeStore = 0 ;
static set < void * > myAllocFreeLockers;
void MyAlloc :: lockFree ()
void MyAlloc :: lockFree (void * addr)
{
// remember address of locker
myAllocFreeLockers.insert( addr );
_freeAllowed = false;
}
void MyAlloc :: unlockFree ()
void MyAlloc :: unlockFree (void * addr)
{
_freeAllowed = true;
myAllocFreeLockers.erase( addr );
// only if no-one else has locked
if( myAllocFreeLockers.empty () )
{
_freeAllowed = true;
}
}
void * MyAlloc :: operator new (size_t s) throw (OutOfMemoryException)
......
......@@ -44,10 +44,10 @@ class MyAlloc {
friend class Initializer;
// if called, freeing objects is allowed again
static void unlockFree();
static void unlockFree(void *);
// if called free of objects is not allowed
static void lockFree ();
static void lockFree (void *);
protected :
MyAlloc () {}
~MyAlloc () {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment