Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_Fad_MemPoolManagerImp.hpp
Go to the documentation of this file.
1 // $Id$
2 // $Source$
3 // @HEADER
4 // ***********************************************************************
5 //
6 // Sacado Package
7 // Copyright (2006) Sandia Corporation
8 //
9 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
10 // the U.S. Government retains certain rights in this software.
11 //
12 // This library is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU Lesser General Public License as
14 // published by the Free Software Foundation; either version 2.1 of the
15 // License, or (at your option) any later version.
16 //
17 // This library is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 // Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public
23 // License along with this library; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
25 // USA
26 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
27 // (etphipp@sandia.gov).
28 //
29 // ***********************************************************************
30 // @HEADER
31 
32 template <typename T>
33 inline
35  num_fad(nfad),
36  poolMap()
37 {
38 }
39 
40 template <typename T>
41 inline
43 {
44  for (typename MapType::iterator i = poolMap.begin();
45  i != poolMap.end(); ++i)
46  delete i->second;
47 }
48 
49 template <typename T>
52 
53  // Find the memory pool
54  typename MapType::iterator i = poolMap.find(dim);
55  if (i != poolMap.end())
56  return i->second;
57 
58  // Create a new pool
59  unsigned int pre_alloc = 0;
60  if (poolMap.begin() != poolMap.end())
61  pre_alloc = poolMap.begin()->second->numChunks();
62  MemPool* pool = new MemPool(sizeof(T)*dim, num_fad, pre_alloc);
63  poolMap[dim] = pool;
64 
65  return pool;
66 }
MemPool * getMemoryPool(unsigned int dim)
Get memory pool for supplied dimension dim.
#define T
Definition: Sacado_rad.hpp:573
MemPoolManager(unsigned int nfad)
Constructor.
if(first)
Definition: uninit.c:101