46 #ifndef LIB_SIMPLE_ALLOCATOR_H 47 #define LIB_SIMPLE_ALLOCATOR_H 56 #include <boost/static_assert.hpp> 79 :
public std::allocator<TY>
91 allocationCount()
const 93 return allocCnt_.get<XX>();
119 template<
class XX>
size_t allocationCount()
const {
return 0; }
120 template<
class XX>
void incrementCount() { }
121 template<
class XX>
void decrementCount() { }
142 template<
typename TYPES
157 TRACE (memory,
"allocate «%s»", util::typeStr<XX>().c_str());
159 COUNTER::template incrementCount<XX>();
165 releaseSlot (XX*
entry)
167 TRACE (memory,
"release «%s»", util::typeStr<XX>().c_str());
169 COUNTER::template decrementCount<XX>();
175 ___assertSupportedType()
177 typedef typename TYPES::List PreconfiguredTypes;
180 BOOST_STATIC_ASSERT (IsSupportedType::value);
188 #define _EXCEPTION_SAFE_INVOKE(_CTOR_) \ 190 ___assertSupportedType<XX>(); \ 191 XX* storage = allocateSlot<XX>(); \ 194 return (new(storage) _CTOR_ ); \ 198 releaseSlot<XX>(storage); \ 206 _EXCEPTION_SAFE_INVOKE ( XX() )
210 template<
class XX,
typename P1>
214 _EXCEPTION_SAFE_INVOKE ( XX (p1) )
225 _EXCEPTION_SAFE_INVOKE ( XX (p1,p2) )
237 _EXCEPTION_SAFE_INVOKE ( XX (p1,p2,p3) )
250 _EXCEPTION_SAFE_INVOKE ( XX (p1,p2,p3,p4) )
262 create (P1& p1, P2& p2, P3& p3, P4& p4, P5& p5)
264 _EXCEPTION_SAFE_INVOKE ( XX (p1,p2,p3,p4,p5) )
267 #undef _EXCEPTION_SAFE_INVOKE 276 ___assertSupportedType<XX>();
284 WARN (common_dbg,
"dtor of «%s» failed: %s", util::typeStr(entry).c_str()
287 releaseSlot<XX> (
entry);
296 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.