11 #ifndef HANDLER_ALLOCATOR_HPP 12 #define HANDLER_ALLOCATOR_HPP 15 #include <boost/aligned_storage.hpp> 16 #include <boost/noncopyable.hpp> 23 :
private boost::noncopyable
33 if (!in_use_ && size < storage_.size)
36 return storage_.address();
39 return ::operator
new(size);
44 if (pointer == storage_.address())
50 ::operator
delete(pointer);
56 boost::aligned_storage<1024> storage_;
65 template <
typename Handler>
75 template <
typename Arg1>
81 template <
typename Arg1,
typename Arg2>
90 return this_handler->allocator_.
allocate(size);
105 template <
typename Handler>
112 #endif // HANDLER_ALLOCATOR_HPP custom_alloc_handler(handler_allocator &a, Handler h)
void deallocate(void *pointer)
void operator()(Arg1 arg1)
custom_alloc_handler< Handler > make_custom_alloc_handler(handler_allocator &a, Handler h)
void operator()(Arg1 arg1, Arg2 arg2)
void * allocate(std::size_t size)
friend void asio_handler_deallocate(void *pointer, std::size_t, custom_alloc_handler< Handler > *this_handler)
friend void * asio_handler_allocate(std::size_t size, custom_alloc_handler< Handler > *this_handler)