40 #define DEFINE_SM_ALLOC(type) \ 41 void* type::operator new(size_t s) \ 43 return smlevel_0::allocator.allocate<type>(s);\ 46 void type::operator delete(void* p, size_t s)\ 48 smlevel_0::allocator.release<type>((type*) p, s);\ 58 template<
typename T,
size_t Alignment = sizeof(T)>
74 static_assert(Alignment > 0 && (Alignment & (Alignment - 1)) == 0,
75 "Alignment argument of memalign_allocator must be power of 2");
95 inline const_pointer
address(const_reference r)
const {
99 inline void construct(pointer p, const_reference value) {
100 new(p) value_type(value);
108 return size_type(-1) /
sizeof(
T);
119 pointer
allocate(size_type count, const_pointer = 0) {
121 int res = posix_memalign((
void**)&p, Alignment,
sizeof(value_type) * count);
123 throw std::bad_alloc();
134 #endif // __ALLOCATOR_H
void * allocate(size_t n)
Definition: allocator.h:15
T & reference
Definition: allocator.h:66
size_type max_size() const
Definition: allocator.h:107
memalign_allocator(const memalign_allocator &)
Definition: allocator.h:84
A transaction. Internal to the storage manager.This class may be used in a limited way for the handli...
Definition: xct.h:185
bool operator==(PooledAllocator< T > const &left, PooledAllocator< U > const &right)
Returns true if objects allocated from one pool can be deallocated from the other.
Definition: stl_pooled_alloc.h:172
const T & const_reference
Definition: allocator.h:68
Definition: allocator.h:59
T * pointer
Definition: allocator.h:62
~memalign_allocator()
Definition: allocator.h:89
Represents a transactional log record.
Definition: logrec.h:143
pointer address(reference r)
Definition: allocator.h:91
void release(void *p, size_t)
Definition: allocator.h:19
bool operator!=(const memalign_allocator &rhs)
Definition: allocator.h:115
memalign_allocator(const memalign_allocator< U, Alignment > &)
Definition: allocator.h:87
memalign_allocator()
Definition: allocator.h:82
Definition: allocator.h:24
T value_type
Definition: allocator.h:60
Definition: allocator.h:13
const_pointer address(const_reference r) const
Definition: allocator.h:95
const T * const_pointer
Definition: allocator.h:64
pointer allocate(size_type count, const_pointer=0)
Definition: allocator.h:119
std::ptrdiff_t difference_type
Definition: allocator.h:72
std::size_t size_type
Definition: allocator.h:70
void construct(pointer p, const_reference value)
Definition: allocator.h:99
memalign_allocator< U, Alignment > other
Definition: allocator.h:79
void destroy(pointer p)
Definition: allocator.h:103
bool operator==(const memalign_allocator &)
Definition: allocator.h:111
#define T
Definition: w_okvl_inl.h:45
void deallocate(pointer p, size_t=1)
Definition: allocator.h:129
Definition: allocator.h:78