27 #ifndef EMBB_BASE_MEMORY_ALLOCATION_H_ 28 #define EMBB_BASE_MEMORY_ALLOCATION_H_ 30 #include <embb/base/exceptions.h> 31 #include <embb/base/internal/config.h> 32 #include <embb/base/c/internal/unused.h> 37 #include <embb/base/c/memory_allocation.h> 77 template<
typename Type>
81 return new(memory) Type();
107 template<
typename Type,
typename Arg1, ...>
119 template<
typename Type,
typename Arg1>
120 static Type*
New(Arg1 arg1) {
123 return new(memory) Type(arg1);
129 template<
typename Type,
typename Arg1,
typename Arg2>
130 static Type*
New(Arg1 arg1, Arg2 arg2) {
133 return new(memory) Type(arg1, arg2);
139 template<
typename Type,
typename Arg1,
typename Arg2,
typename Arg3>
140 static Type*
New(Arg1 arg1, Arg2 arg2, Arg3 arg3) {
143 return new(memory) Type(arg1, arg2, arg3);
149 template<
typename Type,
typename Arg1,
typename Arg2,
typename Arg3,
151 static Type*
New(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4) {
154 return new(memory) Type(arg1, arg2, arg3, arg4);
160 template<
typename Type,
typename Arg1,
typename Arg2,
typename Arg3,
161 typename Arg4,
typename Arg5>
162 static Type*
New(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5) {
165 return new(memory) Type(arg1, arg2, arg3, arg4, arg5);
168 #endif // else DOXYGEN 175 template<
typename Type>
181 embb_free(static_cast<void*>(to_delete));
358 static void*
operator new(
373 static void operator delete(
408 static void*
operator new[](
423 static void operator delete[](
463 static void*
operator new(
476 static void operator delete(
498 static void*
operator new[](
513 static void operator delete[](
524 template <
typename Type>
537 template <
typename OtherType>
struct rebind {
555 template <
typename Type>
582 template <
typename OtherType>
struct rebind {
661 "Amount of requested memory too high");
662 return reinterpret_cast<pointer
> 687 return std::numeric_limits<size_type>::max() /
sizeof(value_type);
698 const value_type& val
701 new(p)value_type(val);
727 template <
typename Type>
740 template <
typename OtherType>
struct rebind {
758 template<
typename Type >
785 template <
typename OtherType>
struct rebind {
809 template<
typename OtherType>
835 if (n > this->max_size())
837 "Amount of requested memory too high");
838 return reinterpret_cast<pointer
> 870 template<
typename T,
typename U>
888 template<
typename T,
typename U>
908 template<
typename T,
typename U>
928 template<
typename T,
typename U>
936 #include <embb/base/internal/memory_allocation-inl.h> 938 #endif // EMBB_BASE_MEMORY_ALLOCATION_H_ Definition: lock_free_mpmc_queue.h:40
Rebind allocator to type OtherType.
Definition: memory_allocation.h:582
Allocator according to the C++ standard.
Definition: memory_allocation.h:728
void deallocate(pointer p, size_type)
Deallocates storage of destroyed elements.
Definition: memory_allocation.h:847
Indicates lack of memory necessary to allocate a resource.
Definition: exceptions.h:196
Type * pointer
Pointer to element type.
Definition: memory_allocation.h:565
Allocator< OtherType > other
Type to rebind to.
Definition: memory_allocation.h:584
AllocatorCacheAligned(const AllocatorCacheAligned< OtherType > &)
Constructs allocator object.
Definition: memory_allocation.h:810
static void Free(void *ptr)
Frees memory that has been allocated by Allocation::Allocate() for some pointer ptr.
void embb_free(void *ptr)
Frees memory that has been allocated by embb_alloc() for some pointer ptr.
Allocator(const Allocator &)
Copies allocator object.
Definition: memory_allocation.h:595
size_t size_type
Quantity of elements type.
Definition: memory_allocation.h:762
void deallocate(pointer p, size_type)
Deallocates storage of destroyed elements.
Definition: memory_allocation.h:671
static void FreeAligned(void *ptr)
Frees memory that has been allocated by Allocation::AllocateAligned() or Allocation::AllocateCacheAli...
ptrdiff_t difference_type
Difference between two pointers type.
Definition: memory_allocation.h:765
pointer allocate(size_type n, const void *=0)
Allocates but doesn't initialize storage for elements of type Type.
Definition: memory_allocation.h:653
static size_t AllocatedBytes()
Returns the total number of bytes currently allocated.
size_t size_type
Quantity of elements type.
Definition: memory_allocation.h:559
const Type * const_pointer
Pointer to constant element type.
Definition: memory_allocation.h:771
Overloaded new/delete operators.
Definition: memory_allocation.h:446
Type & reference
Reference to element type.
Definition: memory_allocation.h:571
pointer allocate(size_type n, const void *=0)
Allocates but doesn't initialize storage for elements of type Type.
Definition: memory_allocation.h:829
Rebind allocator to type OtherType.
Definition: memory_allocation.h:785
Allocator according to the C++ standard.
Definition: memory_allocation.h:525
static Type * New()
Allocates memory for an instance of type Type and default-initializes it.
Definition: memory_allocation.h:78
Type value_type
Element type.
Definition: memory_allocation.h:577
static void * Allocate(size_t size)
Allocates size bytes of memory (unaligned).
const Type & const_reference
Reference to constant element type.
Definition: memory_allocation.h:777
Type value_type
Element type.
Definition: memory_allocation.h:780
Overloaded new/delete operators.
Definition: memory_allocation.h:341
Allocator< OtherType > other
Type to rebind to.
Definition: memory_allocation.h:787
Allocator(const Allocator< OtherType > &)
Constructs allocator object.
Definition: memory_allocation.h:605
pointer address(reference x) const
Gets address of an object.
Definition: memory_allocation.h:623
void construct(pointer p, const value_type &val)
Initializes elements of allocated storage with specified value.
Definition: memory_allocation.h:695
const_pointer address(const_reference x) const
Gets address of a constant object.
Definition: memory_allocation.h:637
~Allocator()
Destructs allocator object.
Definition: memory_allocation.h:614
~AllocatorCacheAligned()
Destructs allocator object.
Definition: memory_allocation.h:818
bool operator!=(const Duration< Tick > &lhs, const Duration< Tick > &rhs)
Compares two durations (inequality).
Definition: duration.h:183
void * embb_alloc(size_t size)
Allocates size bytes of memory.
static void * AllocateAligned(size_t alignment, size_t size)
Allocates size bytes of memory with alignment alignment.
Type & reference
Reference to element type.
Definition: memory_allocation.h:774
AllocatorCacheAligned(const AllocatorCacheAligned &a)
Copies allocator object.
Definition: memory_allocation.h:798
size_type max_size() const
Allocation maximum
Definition: memory_allocation.h:686
const Type & const_reference
Reference to constant element type.
Definition: memory_allocation.h:574
static void Delete(Type *to_delete)
Destructs an instance of type Type and frees the allocated memory.
Definition: memory_allocation.h:176
AllocatorCacheAligned()
Constructs allocator object.
Definition: memory_allocation.h:793
ptrdiff_t difference_type
Difference between two pointers type.
Definition: memory_allocation.h:562
Type * pointer
Pointer to element type.
Definition: memory_allocation.h:768
Allocator()
Constructs allocator object.
Definition: memory_allocation.h:590
static void * AllocateCacheAligned(size_t size)
Allocates size bytes of cache-aligned memory.
const Type * const_pointer
Pointer to constant element type.
Definition: memory_allocation.h:568
Common (static) functionality for unaligned and aligned memory allocation.
Definition: memory_allocation.h:55
bool operator==(const Duration< Tick > &lhs, const Duration< Tick > &rhs)
Compares two durations (equality).
Definition: duration.h:166
void destroy(pointer p)
Destroys elements of initialized storage.
Definition: memory_allocation.h:709