mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
lifetime of BlockAllocator, and mutex
This commit is contained in:
parent
933c93da3a
commit
2c14dd6350
@ -170,6 +170,8 @@ namespace netgen
|
||||
/// store splinesurfaces, such that added ones do not get deleted before geometry does
|
||||
Array<shared_ptr<SplineSurface>> spline_surfaces;
|
||||
|
||||
shared_ptr<BlockAllocator> solid_ball = Solid::ball;
|
||||
|
||||
public:
|
||||
CSGeometry ();
|
||||
CSGeometry (const string & afilename);
|
||||
|
@ -1842,5 +1842,6 @@ namespace netgen
|
||||
|
||||
|
||||
|
||||
BlockAllocator Solid :: ball(sizeof (Solid));
|
||||
// BlockAllocator Solid :: ball(sizeof (Solid));
|
||||
shared_ptr<BlockAllocator> Solid :: ball = make_shared<BlockAllocator>(sizeof (Solid));
|
||||
}
|
||||
|
@ -161,15 +161,15 @@ namespace netgen
|
||||
static Solid * CreateSolid (istream & ist, const SymbolTable<Solid*> & solids);
|
||||
|
||||
|
||||
static BlockAllocator ball;
|
||||
static shared_ptr<BlockAllocator> ball;
|
||||
void * operator new(size_t /* s */)
|
||||
{
|
||||
return ball.Alloc();
|
||||
return ball->Alloc();
|
||||
}
|
||||
|
||||
void operator delete (void * p)
|
||||
{
|
||||
ball.Free (p);
|
||||
ball->Free (p);
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
static mutex block_allocator_mutex;
|
||||
// static mutex block_allocator_mutex;
|
||||
|
||||
BlockAllocator :: BlockAllocator (unsigned asize, unsigned ablocks)
|
||||
: bablocks (0)
|
||||
|
@ -23,6 +23,7 @@ private:
|
||||
void * freelist;
|
||||
///
|
||||
Array<char*> bablocks;
|
||||
mutex block_allocator_mutex;
|
||||
public:
|
||||
///
|
||||
BlockAllocator (unsigned asize, unsigned ablocks = 100);
|
||||
|
Loading…
Reference in New Issue
Block a user