Honeycomb  0.1
Component-Model Framework
Classes | Macros | Typedefs | Functions
Memory Util

Memory-management and allocators. More...

Classes

struct  honey::Allocator< Subclass, T >::rebind< U >
 
class  honey::Allocator< Subclass, T >
 std::allocator compatible allocator More...
 
class  honey::AllocatorObject< Alloc >
 Objects that inherit from this class will use Alloc for new/delete ops. More...
 
struct  honey::DefaultAllocator< T, class >
 Returns T::Allocator<T> if available, otherwise std::allocator<T> More...
 
struct  honey::DefaultAllocator< T[], std::true_type >
 
struct  honey::DefaultAllocator< T, typename mt::True< typename T::template Allocator< T > >::type >
 
struct  honey::finalize< T, Alloc >
 Functor to delete a pointer. More...
 
struct  honey::finalize< T[], std::allocator< T > >
 Specialization for array. More...
 
struct  honey::finalize< void, std::allocator< void > >
 Specialization for void. More...
 
struct  honey::MemPool::Bucket::Handle
 Enables blocks to be referenced via index rather than pointer so that they can include a tag while still maintaining a swappable size. More...
 
struct  honey::MemPool::Bucket::TaggedHandle
 Holds block handle and tag to prevent lock-free ABA issues. More...
 
struct  honey::MemPool::Bucket::BlockHeader::Debug
 
struct  honey::MemPool::Bucket::BlockHeader
 Bucket block header. More...
 
struct  honey::MemPool::Heap::BlockHeader::Debug
 
struct  honey::MemPool::Heap::BlockHeader
 Heap block header. More...
 
class  honey::MemPool
 Memory pool. More...
 
class  honey::MemPoolAllocator< Subclass, T >
 MemPool allocator. More...
 
class  honey::SharedObj< Subclass >
 Reference-counted object for intrusive shared pointers. More...
 
class  honey::UniquePtr< T, Fin >
 Pointer to a unique, non-shared, object. Finalizer is run upon destruction (deletes object by default) if pointer is not null. More...
 
class  honey::WeakPtr< T >
 Point to a shared object without holding a reference. The object is accessible through a lock, which prevents unexpected destruction. More...
 
class  honey::SharedPtr< T >
 Combined intrusive/non-intrusive smart pointer. Can reference and share any object automatically. More...
 
class  honey::SmallAllocator< T >
 Global allocator for small memory blocks. To provide a custom pool define SmallAllocator_createSingleton_ and implement SmallAllocator_createSingleton(). More...
 

Macros

#define new_   new (__FILE__, __LINE__)
 Global new_, use in place of new keyword to provide allocator with debug info. More...
 

Typedefs

typedef AllocatorObject< SmallAllocator > honey::SmallAllocatorObject
 Inherit from this class to use the small block allocator. More...
 

Functions

void * operator new (size_t size, const char *srcFile, int srcLine)
 
void * operator new[] (size_t size, const char *srcFile, int srcLine)
 
template<class T >
T * honey::alloc (szt count=1)
 Allocate memory for count number of T objects. Objects are not constructed. More...
 
template<class T >
void honey::free (T *&p)
 Deallocate memory and set pointer to null. Object is not destroyed. More...
 
template<class T >
void honey::free (T *const &p)
 
template<class T >
T * honey::alignFloor (T *p, szt bytes)
 Align a pointer to the previous byte boundary bytes. Does nothing if p is already on boundary. Alignment must be a power of two. More...
 
template<class T >
T * honey::alignCeil (T *p, szt bytes)
 Align a pointer to the next byte boundary bytes. Does nothing if p is already on boundary. Alignment must be a power of two. More...
 
template<class T , class Alloc >
T * honey::allocAligned (szt count, szt align_, Alloc &&a)
 Allocate memory with alignment. Alignment must be a power of two. Allocator element type must be int8. More...
 
template<class T >
T * honey::allocAligned (szt count, szt align)
 Allocate memory with alignment using default allocator. More...
 
template<class T , class Alloc >
void honey::freeAligned (T *p, Alloc &&a)
 Deallocate aligned memory. Allocator element type must be int8. More...
 
template<class T >
void honey::freeAligned (T *p)
 Deallocate aligned memory using default allocator. More...
 
template<class T >
void honey::delete_ (T *&p)
 Destruct object, free memory and set pointer to null. More...
 
template<class T >
void honey::delete_ (T *const &p)
 
template<class T , class Alloc >
void honey::delete_ (T *&p, Alloc &&a)
 Destruct object, free memory using allocator and set pointer to null. More...
 
template<class T , class Alloc >
void honey::delete_ (T *const &p, Alloc &&a)
 
template<class T >
void honey::deleteArray (T *&p)
 Destruct all array objects, free memory and set pointer to null. More...
 
template<class T >
void honey::deleteArray (T *const &p)
 
MemPool * honey::SmallAllocator_createSingleton ()
 Default implementation. More...
 
template<class T , class Alloc , class... Args, typename mt::disable_if< mt::is_base_of< priv::SharedObj_tag, T >::value, int >::type = 0>
SharedPtr< T > alloc_shared (Alloc &&a, Args &&...args)
 Create a shared ptr to an object of type T constructed with args. The object and the internal control block are allocated together in a single allocation. More...
 
template<class T , class... Args, class Alloc = typename DefaultAllocator<T>::type>
SharedPtr< T > make_shared (Args &&...args)
 alloc_shared() using T::Allocator if available, otherwise std::allocator More...
 
template<class T , class U >
SharedPtr< T > static_pointer_cast (const SharedPtr< U > &rhs)
 
template<class T , class U >
SharedPtr< T > dynamic_pointer_cast (const SharedPtr< U > &rhs)
 
template<class T , class U >
SharedPtr< T > const_pointer_cast (const SharedPtr< U > &rhs)
 
template<class T , class Alloc , class... Args, class Fin = finalize<T,typename mt::removeRef<Alloc>::type>>
UniquePtr< T, Fin > alloc_unique (Alloc &&a, Args &&...args)
 Create a unique ptr to an object of type T constructed with args. More...
 
template<class T , class... Args, typename mt::disable_if< std::is_array< T >::value, int >::type = 0, class Alloc = typename DefaultAllocator<T>::type>
UniquePtr< T > make_unique (Args &&...args)
 alloc_unique() using T::Allocator if available, otherwise std::allocator More...
 
template<class T , class... Args, typename std::enable_if< std::is_array< T >::value, int >::type = 0>
UniquePtr< T > make_unique (szt size)
 Create a unique ptr to an array of size number of elements. More...
 
template<class T , class... Args, typename std::enable_if< std::is_array< T >::value, int >::type = 0>
UniquePtr< T > make_unique_auto_size (Args &&...args)
 Create a unique ptr to an array with deduced size. More...
 

Detailed Description

Memory-management and allocators.

Macro Definition Documentation

#define new_   new (__FILE__, __LINE__)

Global new_, use in place of new keyword to provide allocator with debug info.

Typedef Documentation

typedef AllocatorObject<SmallAllocator> honey::SmallAllocatorObject

Inherit from this class to use the small block allocator.

Function Documentation

template<class T >
T* honey::alignCeil ( T *  p,
szt  bytes 
)

Align a pointer to the next byte boundary bytes. Does nothing if p is already on boundary. Alignment must be a power of two.

template<class T >
T* honey::alignFloor ( T *  p,
szt  bytes 
)

Align a pointer to the previous byte boundary bytes. Does nothing if p is already on boundary. Alignment must be a power of two.

template<class T >
T* honey::alloc ( szt  count = 1)

Allocate memory for count number of T objects. Objects are not constructed.

template<class T , class Alloc , class... Args, typename mt::disable_if< mt::is_base_of< priv::SharedObj_tag, T >::value, int >::type = 0>
SharedPtr< T > alloc_shared ( Alloc &&  a,
Args &&...  args 
)
related

Create a shared ptr to an object of type T constructed with args. The object and the internal control block are allocated together in a single allocation.

template<class T , class Alloc , class... Args, class Fin = finalize<T,typename mt::removeRef<Alloc>::type>>
UniquePtr< T, Fin > alloc_unique ( Alloc &&  a,
Args &&...  args 
)
related

Create a unique ptr to an object of type T constructed with args.

template<class T , class Alloc >
T* honey::allocAligned ( szt  count,
szt  align_,
Alloc &&  a 
)

Allocate memory with alignment. Alignment must be a power of two. Allocator element type must be int8.

template<class T >
T* honey::allocAligned ( szt  count,
szt  align 
)

Allocate memory with alignment using default allocator.

template<class T , class U >
SharedPtr< T > const_pointer_cast ( const SharedPtr< U > &  rhs)
related
template<class T >
void honey::delete_ ( T *&  p)

Destruct object, free memory and set pointer to null.

template<class T >
void honey::delete_ ( T *const &  p)
template<class T , class Alloc >
void honey::delete_ ( T *&  p,
Alloc &&  a 
)

Destruct object, free memory using allocator and set pointer to null.

template<class T , class Alloc >
void honey::delete_ ( T *const &  p,
Alloc &&  a 
)
template<class T >
void honey::deleteArray ( T *&  p)

Destruct all array objects, free memory and set pointer to null.

template<class T >
void honey::deleteArray ( T *const &  p)
template<class T , class U >
SharedPtr< T > dynamic_pointer_cast ( const SharedPtr< U > &  rhs)
related
template<class T >
void honey::free ( T *&  p)

Deallocate memory and set pointer to null. Object is not destroyed.

template<class T >
void honey::free ( T *const &  p)
template<class T , class Alloc >
void honey::freeAligned ( T *  p,
Alloc &&  a 
)

Deallocate aligned memory. Allocator element type must be int8.

template<class T >
void honey::freeAligned ( T *  p)

Deallocate aligned memory using default allocator.

template<class T , class... Args, class Alloc = typename DefaultAllocator<T>::type>
SharedPtr< T > make_shared ( Args &&...  args)
related

alloc_shared() using T::Allocator if available, otherwise std::allocator

template<class T , class... Args, typename mt::disable_if< std::is_array< T >::value, int >::type = 0, class Alloc = typename DefaultAllocator<T>::type>
UniquePtr< T > make_unique ( Args &&...  args)
related

alloc_unique() using T::Allocator if available, otherwise std::allocator

template<class T , class... Args, typename std::enable_if< std::is_array< T >::value, int >::type = 0>
UniquePtr< T > make_unique ( szt  size)
related

Create a unique ptr to an array of size number of elements.

template<class T , class... Args, typename std::enable_if< std::is_array< T >::value, int >::type = 0>
UniquePtr< T > make_unique_auto_size ( Args &&...  args)
related

Create a unique ptr to an array with deduced size.

void* operator new ( size_t  size,
const char *  srcFile,
int  srcLine 
)
inline
void* operator new[] ( size_t  size,
const char *  srcFile,
int  srcLine 
)
inline
MemPool * honey::SmallAllocator_createSingleton ( )
inline

Default implementation.

template<class T , class U >
SharedPtr< T > static_pointer_cast ( const SharedPtr< U > &  rhs)
related