3 #ifndef CDSUNIT_MICHAEL_ALLOC_H
4 #define CDSUNIT_MICHAEL_ALLOC_H
6 #include <cds/memory/michael/allocator.h>
11 typedef cds::memory::michael::Heap<
12 cds::memory::michael::opt::check_bounds< cds::memory::michael::debug_bound_checking >
14 extern michael_heap s_MichaelHeap;
17 class MichaelAllocator
19 typedef std::allocator<T> std_allocator;
21 // Declare typedefs from std::allocator
22 typedef typename std_allocator::const_pointer const_pointer;
23 typedef typename std_allocator::pointer pointer;
24 typedef typename std_allocator::const_reference const_reference;
25 typedef typename std_allocator::reference reference;
26 typedef typename std_allocator::difference_type difference_type;
27 typedef typename std_allocator::size_type size_type;
28 typedef typename std_allocator::value_type value_type;
30 // Allocation function
31 pointer allocate( size_type _Count, const void* /*_Hint*/ = nullptr )
33 return reinterpret_cast<pointer>( s_MichaelHeap.alloc( sizeof(T) * _Count ));
36 // Deallocation function
37 void deallocate( pointer _Ptr, size_type /*_Count*/ )
39 s_MichaelHeap.free( _Ptr );
42 pointer address( reference r ) const
46 const_pointer address( const_reference r ) const
50 void construct( pointer p, const T& val )
52 return new( p ) T( val );
54 void destroy( pointer p )
59 // Rebinding allocator to other type
60 template <class Other>
62 typedef MichaelAllocator<Other> other;
67 #endif // #ifndef CDSUNIT_MICHAEL_ALLOC_H