mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter > Class Template Reference

#include <mn_lock_storage.hpp>

+ Collaboration diagram for mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >:

Public Types

using allocator_category = typename allocator::allocator_category
 
using value_type = void
 
using pointer = void *
 
using const_pointer = const void *
 
using difference_type = mn::ptrdiff_t
 
using size_type = size_t
 
using is_thread_safe = mn::true_type
 
using lock_type = TMutex
 
using allocator_impl = TAllocator
 
using filter_type = TFilter
 
using self_type = basic_threadsafed_allocator< TMutex, TAllocator, TFilter >
 
using lock_guard = mn::basic_autolock< lock_type >
 

Public Member Functions

 basic_threadsafed_allocator () noexcept
 
 basic_threadsafed_allocator (const lock_type &lckObject) noexcept
 
 basic_threadsafed_allocator (const lock_type &lckObject, const filter_type &_fFilter) noexcept
 
pointer allocate (size_t size, size_t alignment)
 malloc() a buffer in a given TAllocator and cheak with the given TFilter is this okay to alloc More...
 
pointer allocate (size_t size)
 malloc() a buffer in a given TAllocator and cheak with the given TFilter is this okay to alloc More...
 
pointer allocate (size_t count, size_t size, size_t alignment=0)
 malloc() a buffer in a given TAllocator and cheak with the given TFilter is this okay to alloc More...
 
void deallocate (pointer address, size_t size, size_t alignment) noexcept
 free() a buffer in a given heap. More...
 
void deallocate (pointer address, size_t size) noexcept
 free() a buffer in a given heap. More...
 
void deallocate (pointer address, size_t count, size_t size, size_t alignment) noexcept
 free() a buffer in a given heap. More...
 
template<class Type , typename... Args>
Type * construct (Args &&... args)
 Construct a object from allocated impl. More...
 
template<class Type >
void destroy (Type *address) noexcept
 Deconstruct a object (call deconstructor) and free the memory. More...
 
size_t get_max_alocator_size () const noexcept
 Get the maximal size to allocate. More...
 
void lock (unsigned long xTicksToWait=0) const
 
void unlock () const noexcept
 
void set_ticksToWait (unsigned long xTicksToWait)
 
bool is_locked ()
 
 basic_threadsafed_allocator (const self_type &other) noexcept=delete
 
self_typeoperator= (const basic_threadsafed_allocator &other) noexcept=delete
 

Private Attributes

lock_type m_lockObjct
 
filter_type m_fFilter
 
unsigned long m_xTicksToWait
 

Detailed Description

template<class TMutex, class TAllocator, class TFilter = basic_allocator_filter>
class mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >

The basic allocater for all allocator impl in this library, with thread-safed version.

Member Typedef Documentation

◆ allocator_category

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::allocator_category = typename allocator::allocator_category

◆ allocator_impl

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::allocator_impl = TAllocator

◆ const_pointer

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::const_pointer = const void*

◆ difference_type

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::difference_type = mn::ptrdiff_t

◆ filter_type

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::filter_type = TFilter

◆ is_thread_safe

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::is_thread_safe = mn::true_type

◆ lock_guard

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::lock_guard = mn::basic_autolock<lock_type>

◆ lock_type

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::lock_type = TMutex

◆ pointer

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::pointer = void*

◆ self_type

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::self_type = basic_threadsafed_allocator<TMutex, TAllocator, TFilter>

◆ size_type

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::size_type = size_t

◆ value_type

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::value_type = void

Constructor & Destructor Documentation

◆ basic_threadsafed_allocator() [1/4]

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::basic_threadsafed_allocator ( )
inlinenoexcept

◆ basic_threadsafed_allocator() [2/4]

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::basic_threadsafed_allocator ( const lock_type lckObject)
inlinenoexcept

◆ basic_threadsafed_allocator() [3/4]

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::basic_threadsafed_allocator ( const lock_type lckObject,
const filter_type _fFilter 
)
inlinenoexcept

◆ basic_threadsafed_allocator() [4/4]

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::basic_threadsafed_allocator ( const self_type other)
deletenoexcept

Member Function Documentation

◆ allocate() [1/3]

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
pointer mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::allocate ( size_t  count,
size_t  size,
size_t  alignment = 0 
)
inline

malloc() a buffer in a given TAllocator and cheak with the given TFilter is this okay to alloc

Parameters
sizeThe size of the Type
countThe count of the array
alignment
Returns
Pointer to new memory, or NULL if allocation fails.

◆ allocate() [2/3]

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
pointer mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::allocate ( size_t  size)
inline

malloc() a buffer in a given TAllocator and cheak with the given TFilter is this okay to alloc

Parameters
sizeSize of desired buffer.
Returns
Pointer to new memory, or NULL if allocation fails.

◆ allocate() [3/3]

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
pointer mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::allocate ( size_t  size,
size_t  alignment 
)
inline

malloc() a buffer in a given TAllocator and cheak with the given TFilter is this okay to alloc

Parameters
sizeSize of desired buffer.
alignment
Returns
Pointer to new memory, or NULL if allocation fails.

◆ construct()

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
template<class Type , typename... Args>
Type* mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::construct ( Args &&...  args)
inline

Construct a object from allocated impl.

Template Parameters
TypeThe type of the object.
Parameters
ArgsThe arguments for the constructer of the object.

◆ deallocate() [1/3]

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
void mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::deallocate ( pointer  address,
size_t  count,
size_t  size,
size_t  alignment 
)
inlinenoexcept

free() a buffer in a given heap.

Parameters
addressThe address to free
countThe count of the array
sizeThe size of the Type
alignment

◆ deallocate() [2/3]

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
void mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::deallocate ( pointer  address,
size_t  size 
)
inlinenoexcept

free() a buffer in a given heap.

Parameters
addressThe address to free.
sizeThe size of the Type

◆ deallocate() [3/3]

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
void mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::deallocate ( pointer  address,
size_t  size,
size_t  alignment 
)
inlinenoexcept

free() a buffer in a given heap.

Parameters
addressThe address to free.
alignment
sizeThe size of the Type

◆ destroy()

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
template<class Type >
void mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::destroy ( Type *  address)
inlinenoexcept

Deconstruct a object (call deconstructor) and free the memory.

Template Parameters
TypeThe type of the object.
Parameters
addressThe pointer of the object to be deconstruct.

◆ get_max_alocator_size()

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
size_t mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::get_max_alocator_size ( ) const
inlinenoexcept

Get the maximal size to allocate.

Returns
The maximal size to allocate.

◆ is_locked()

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
bool mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::is_locked ( )
inline

◆ lock()

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
void mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::lock ( unsigned long  xTicksToWait = 0) const
inline

◆ operator=()

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
self_type& mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::operator= ( const basic_threadsafed_allocator< TMutex, TAllocator, TFilter > &  other)
deletenoexcept

◆ set_ticksToWait()

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
void mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::set_ticksToWait ( unsigned long  xTicksToWait)
inline

◆ unlock()

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
void mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::unlock ( ) const
inlinenoexcept

Member Data Documentation

◆ m_fFilter

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
filter_type mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::m_fFilter
private

◆ m_lockObjct

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
lock_type mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::m_lockObjct
private

◆ m_xTicksToWait

template<class TMutex , class TAllocator , class TFilter = basic_allocator_filter>
unsigned long mn::memory::basic_threadsafed_allocator< TMutex, TAllocator, TFilter >::m_xTicksToWait
private

The documentation for this class was generated from the following file: