|
Boost : |
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2005-12-22 01:03:23
Hi Chris,
I have some doubts about your allocator proposal:
> struct async_server_receive_handler
> {
> async_server_receive_handler(async_server* this_p) : this_p_(this_p) {}
> void operator()(const asio::error& error, std::size_t);
> async_server* this_p_;
> };
>
> template <>
> class asio::handler_alloc_hook<async_server_receive_handler>
> {
> public:
> template <typename Allocator>
> static typename Allocator::pointer allocate(
> async_server_receive_handler& h,
> Allocator& allocator,
> typename Allocator::size_type count)
> {
> return reinterpret_cast<typename Allocator::pointer>(
> h.this_p_->operation_buffer);
> }
>
> template <typename Allocator>
> static void deallocate(
> async_server_receive_handler& h,
> Allocator& allocator,
> typename Allocator::pointer pointer,
> typename Allocator::size_type count)
> {
> }
> };
What does the custom allocator allocate? async_server_receive_handlers?
Because the function is templatized:
template <typename Allocator>
static typename Allocator::pointer allocate(
async_server_receive_handler& h,
Allocator& allocator,
typename Allocator::size_type count)
{
return reinterpret_cast<typename Allocator::pointer>(
h.this_p_->operation_buffer);
}
so what's "Allocator &allocator" object, and what does it allocate?
Can't we know at compile time what type are we going to manage? Also,
should we define different allocators for read, write, accept, and other
events?
Regards,
Ion
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk