From 0623fcb2e57ec510940894b84581b4de8c994a3f Mon Sep 17 00:00:00 2001 From: bangerth Date: Thu, 24 Jan 2008 17:50:19 +0000 Subject: [PATCH] Move the GrowingVectorMemory::Pool functions into the .cc file. This doesn't hurt because the pools are constructed only once per program lifetime, so they do not need to be inlined. This also allows us to move the definitions of the static variables into the .cc file which avoids that they are created more than once. git-svn-id: https://svn.dealii.org/trunk@15678 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/vector_memory.h | 58 ---------------------- deal.II/lac/source/vector_memory.cc | 63 +++++++++++++++++++++++- deal.II/lac/source/vector_memory.inst.in | 14 ++---- 3 files changed, 66 insertions(+), 69 deletions(-) diff --git a/deal.II/lac/include/lac/vector_memory.h b/deal.II/lac/include/lac/vector_memory.h index 0a10028f72..a5ad1bd49c 100644 --- a/deal.II/lac/include/lac/vector_memory.h +++ b/deal.II/lac/include/lac/vector_memory.h @@ -350,64 +350,6 @@ class GrowingVectorMemory : public VectorMemory #ifndef DOXYGEN /* --------------------- inline functions ---------------------- */ -template -inline -GrowingVectorMemory::Pool::Pool() - : - data(0) -{} - - - -template -inline -GrowingVectorMemory::Pool::~Pool() -{ - // Nothing to do if memory was unused. - if (data == 0) return; - - // First, delete all remaining - // vectors. Actually, there should - // be none, if there is no memory - // leak - unsigned int n=0; - for (typename std::vector::iterator i=data->begin(); - i != data->end(); - ++i) - { - if (i->first == true) - ++n; - delete i->second; - } - delete data; -} - - -template -inline -void -GrowingVectorMemory::Pool::initialize(const unsigned int size) -{ - if (data == 0) - { - data = new std::vector(size); - - for (typename std::vector::iterator i= data->begin(); - i != data->end(); - ++i) - { - i->first = false; - i->second = new VECTOR; - } - } -} - - -template -typename GrowingVectorMemory::Pool GrowingVectorMemory::pool; -template -Threads::ThreadMutex GrowingVectorMemory::mutex; - template inline diff --git a/deal.II/lac/source/vector_memory.cc b/deal.II/lac/source/vector_memory.cc index e1a2abf67c..4aef81ff40 100644 --- a/deal.II/lac/source/vector_memory.cc +++ b/deal.II/lac/source/vector_memory.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2007 by the deal.II authors +// Copyright (C) 2007, 2008 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -18,6 +18,67 @@ DEAL_II_NAMESPACE_OPEN + +template +GrowingVectorMemory::Pool::Pool() + : + data(0) +{} + + + +template +GrowingVectorMemory::Pool::~Pool() +{ + // Nothing to do if memory was unused. + if (data == 0) return; + + // First, delete all remaining + // vectors. Actually, there should + // be none, if there is no memory + // leak + unsigned int n=0; + for (typename std::vector::iterator i=data->begin(); + i != data->end(); + ++i) + { + if (i->first == true) + ++n; + delete i->second; + } + delete data; +} + + +template +void +GrowingVectorMemory::Pool::initialize(const unsigned int size) +{ + if (data == 0) + { + data = new std::vector(size); + + for (typename std::vector::iterator i= data->begin(); + i != data->end(); + ++i) + { + i->first = false; + i->second = new VECTOR; + } + } +} + + +template +typename GrowingVectorMemory::Pool GrowingVectorMemory::pool; + +template +Threads::ThreadMutex GrowingVectorMemory::mutex; + + + + + #include "vector_memory.inst" DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/lac/source/vector_memory.inst.in b/deal.II/lac/source/vector_memory.inst.in index 406a44be09..535a739a6c 100644 --- a/deal.II/lac/source/vector_memory.inst.in +++ b/deal.II/lac/source/vector_memory.inst.in @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -16,25 +16,19 @@ for (SCALAR : REAL_SCALARS) { template class VectorMemory >; template class GrowingVectorMemory >; -// template GrowingVectorMemory >::Pool -// GrowingVectorMemory >::pool; + template class VectorMemory >; template class GrowingVectorMemory >; -// template GrowingVectorMemory >::Pool -// GrowingVectorMemory >::pool; } + for (SCALAR : COMPLEX_SCALARS) { template class VectorMemory >; template class GrowingVectorMemory >; -// template GrowingVectorMemory >::Pool -// GrowingVectorMemory >::pool; - + template class VectorMemory >; template class GrowingVectorMemory >; -// template GrowingVectorMemory >::Pool -// GrowingVectorMemory >::pool; } -- 2.39.5