pool_alloc_mixin.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Utils_pool_alloc_mixin_
18 #define HH_SENF_Utils_pool_alloc_mixin_ 1
19 
20 // Custom includes
21 #include <boost/pool/singleton_pool.hpp>
22 
23 //#include "pool_alloc_mixin.mpp"
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 namespace senf {
27 
28  struct pool_alloc_mixin_tag;
29 
57  template <class Self>
59  {
60  public:
66  template <class T=void>
67  struct pool
68  : public boost::singleton_pool< pool_alloc_mixin_tag, sizeof(Self) >
69  {
70  typedef boost::singleton_pool< pool_alloc_mixin_tag, sizeof(Self) > type;
71  };
72 
73  static void * operator new (size_t size);
75  static void operator delete (void *p, size_t size);
77 
78 #ifdef SENF_DEBUG
79  static unsigned long allocCounter();
80  private:
81  static unsigned long allocCounter(long delta);
82 #endif
83  };
84 
85 }
86 
87 //-/////////////////////////////////////////////////////////////////////////////////////////////////
88 //#include "pool_alloc_mixin.cci"
89 //#include "pool_alloc_mixin.ct"
90 #include "pool_alloc_mixin.cti"
91 #endif
92 
93 
94 // Local Variables:
95 // mode: c++
96 // fill-column: 100
97 // c-file-style: "senf"
98 // indent-tabs-mode: nil
99 // ispell-local-dictionary: "american"
100 // compile-command: "scons -u test"
101 // comment-column: 40
102 // End:
Mixin to assign pool allocator to a class.
Templated typedef for the pool used.
boost::singleton_pool< pool_alloc_mixin_tag, sizeof(Self) > type