26-Jun-2013 02:22, cybervadim пишет:
I know Andrey mentioned he was going to work on Allocators a year ago.
In DConf 2013 he described the problems he needs to solve with
Allocators. But I wonder if I am missing the discussion around that - I
tried searching this forum, found a few threads that was not actually a
brain storm for Allocators design.

Please point me in the right direction
or
is there a reason it is not discussed
or
should we open the discussion?


The easiest approach for Allocators design I can imagine would be to let
user specify which Allocator operator new should get the memory from
(introducing a new keyword allocator). This gives a total control, but
assumes user knows what he is doing.

Example:

CustomAllocator ca;
allocator(ca) {
   auto a = new A; // operator new will use ScopeAllocator::malloc()
   auto b = new B;

   free(a); // that should call ScopeAllocator::free()
   // if free() is missing for allocated area, it is a user
responsibility to make sure custom Allocator can handle that
}

Awful. What that extra syntax had brought you? Except that now new is unsafe by design? Other questions involve how does this allocation scope goes inside of functions, what is the mechanism of passing it up and down of call-stack.

Last but not least I fail to see how scoped allocators alone (as presented) solve even half of the problem.

--
Dmitry Olshansky

Reply via email to