Lumiera  0.pre.03
»edit your freedom«
simple-allocator.hpp File Reference

Go to the source code of this file.

Description

Frontend and marker interface for allocating small objects explicitly.

Contrary to the TypedAllocationManager, the SimpleAllocator doesn't provide any ref-counting or tracking facilities, nor does he support bulk de-allocation. Each object needs to be allocated and released by explicit call. The advantage over using std::allocator directly is the shortcut for (placement) construction, and – of course – the ability to exchange the memory model at one central location.

SimpleAllocator instances will be defined for a specific collection of types; for each of those types, there will be an embedded dedicated custom allocator (currently as of 9/2011, just implemented as std::allocator<TY>). Objects of these preconfigured types can be constructed and destroyed through this allocator instance. Each call needs to be done explicitly, with the precise, concrete type to be created or destroyed. This is especially important for the releasing of objects: there is no support for any kind of virtual destruction.

See also
engine::BufferMetadata
TypedAllocationManager (another more elaborate custom allocation scheme)

Definition in file simple-allocator.hpp.

#include "lib/error.hpp"
#include "lib/meta/generator.hpp"
#include "lib/meta/typelist-util.hpp"
#include "lib/meta/util.hpp"
#include "lib/typed-counter.hpp"
#include "include/logging.h"
#include <boost/static_assert.hpp>
#include <memory>

Classes

class  CustomAllocator< TY >
 Policy: use just plain heap allocations whenever you define a specialisation, you are responsible for proper alignment. More...
 
struct  NoInstantiationCount
 Policy: no additional instantiation accounting. More...
 
class  SimpleAllocator< TYPES, COUNTER >
 Frontend for explicit allocations, using a custom allocator. More...
 
struct  UseInstantiationCounting
 Policy: maintain explicit per type instance count. More...
 

Macros

#define _EXCEPTION_SAFE_INVOKE(_CTOR_)
 

Namespaces

 lib
 Implementation namespace for support and library code.
 

Macro Definition Documentation

◆ _EXCEPTION_SAFE_INVOKE

#define _EXCEPTION_SAFE_INVOKE (   _CTOR_)
Value:
\
___assertSupportedType<XX>(); \
XX* storage = allocateSlot<XX>(); \
try \
{ \
return (new(storage) _CTOR_ ); \
} \
catch(...) \
{ \
releaseSlot<XX>(storage); \
throw; \
}

Definition at line 188 of file simple-allocator.hpp.