Re: [asio-users] io_service and allocators
Brought to you by:
chris_kohlhoff
From: Felipe M. de A. <fel...@gm...> - 2009-09-19 23:26:34
|
On Sat, Sep 19, 2009 at 7:37 PM, Christopher Kohlhoff <ch...@ko...> wrote: > > > On Fri, 11 Sep 2009 08:44 -0300, "Felipe Magno de Almeida" > <fel...@gm...> wrote: >> I might not be able to call malloc/new at all in some parts of the >> program. >> I would be willing to add allocator support for asio if you feel it would >> be a good thing. >> I might need to do so anyway, though in a private version. > > I'd consider a service for this (i.e. something derived from > io_service::service). E.g.: > > class allocation_service : public io_service::service > { > static io_service::id id; > void shutdown_service() {} > void* allocate(...) { ... } > void deallocate(...) { ... } > }; > > The user would have to register it using add_service() before doing > anything else. Wouldn't this be reinventing the wheel? There's already an Allocator concept in the Standard Library. > Note that this should not be used for any handler-related allocations. > I.e. these functions would not be used (or used very little) once a > program reaches a steady state. These should use the ADL allocation scheme right? I think there should be a way to change all handler allocation for a io_service as well. I don't want to have to add allocation functions in boost namespace to use boost::bind. > Cheers, > Chris [snip] Regards, -- Felipe Magno de Almeida |