37 #ifndef LIB_SIMPLE_ALLOCATOR_H 38 #define LIB_SIMPLE_ALLOCATOR_H 47 #include <boost/static_assert.hpp> 70 :
public std::allocator<TY>
82 allocationCount()
const 84 return allocCnt_.get<XX>();
110 template<
class XX>
size_t allocationCount()
const {
return 0; }
111 template<
class XX>
void incrementCount() { }
112 template<
class XX>
void decrementCount() { }
133 template<
typename TYPES
148 TRACE (memory,
"allocate «%s»", util::typeStr<XX>().c_str());
150 COUNTER::template incrementCount<XX>();
156 releaseSlot (XX*
entry)
158 TRACE (memory,
"release «%s»", util::typeStr<XX>().c_str());
160 COUNTER::template decrementCount<XX>();
166 ___assertSupportedType()
168 typedef typename TYPES::List PreconfiguredTypes;
171 BOOST_STATIC_ASSERT (IsSupportedType::value);
179 #define _EXCEPTION_SAFE_INVOKE(_CTOR_) \ 181 ___assertSupportedType<XX>(); \ 182 XX* storage = allocateSlot<XX>(); \ 185 return (new(storage) _CTOR_ ); \ 189 releaseSlot<XX>(storage); \ 197 _EXCEPTION_SAFE_INVOKE ( XX() )
201 template<
class XX,
typename P1>
205 _EXCEPTION_SAFE_INVOKE ( XX (p1) )
216 _EXCEPTION_SAFE_INVOKE ( XX (p1,p2) )
228 _EXCEPTION_SAFE_INVOKE ( XX (p1,p2,p3) )
241 _EXCEPTION_SAFE_INVOKE ( XX (p1,p2,p3,p4) )
253 create (P1& p1, P2& p2, P3& p3, P4& p4, P5& p5)
255 _EXCEPTION_SAFE_INVOKE ( XX (p1,p2,p3,p4,p5) )
258 #undef _EXCEPTION_SAFE_INVOKE 267 ___assertSupportedType<XX>();
275 WARN (common_dbg,
"dtor of «%s» failed: %s", util::typeStr(entry).c_str()
278 releaseSlot<XX> (
entry);
287 return COUNTER::template allocationCount<XX>();
Policy: no additional instantiation accounting.
Creating series of type-based contexts.
Utility providing a set of counters, each tied to a specific type.
size_t numSlots() const
diagnostics
AnyPair entry(Query< TY > const &query, typename WrapReturn< TY >::Wrapper &obj)
helper to simplify creating mock table entries, wrapped correctly
XX * create(P1 &p1, P2 &p2)
Helpers for working with lib::meta::Types (i.e.
Metaprogramming: simple helpers for working with lists-of-types.
This header is for including and configuring NoBug.
Implementation namespace for support and library code.
XX * create(P1 &p1, P2 &p2, P3 &p3, P4 &p4)
lumiera_err lumiera_error(void)
Get and clear current error state.
Frontend for explicit allocations, using a custom allocator.
XX * create(P1 &p1, P2 &p2, P3 &p3, P4 &p4, P5 &p5)
Lumiera error handling (C++ interface).
XX * allocateSlot()
forward plain memory allocation
XX * create(P1 &p1, P2 &p2, P3 &p3)
Policy: use just plain heap allocations whenever you define a specialisation, you are responsible fo...
Policy: maintain explicit per type instance count.