Phobos addition formal review: std.experimental.allocator

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 12 08:54:04 PDT 2015


On 6/12/15 4:08 AM, Dicebot wrote:
> Small tip for reviewers: there are quite many modules in proposed
> package but majority is actual allocator implementation. I'd suggest to
> start investigating sources/documentation starting from
> http://erdani.com/d/phobos-prerelease/std_experimental_allocator.html
> and
> http://erdani.com/d/phobos-prerelease/std_experimental_allocator_building_blocks.html
> while using
> http://erdani.com/d/phobos-prerelease/std_experimental_allocator_showcase.html
> as reference for "highlight" examples.

A few more words on that:

Think of std.experimental.allocator as a three-layered cake:

* An untyped layer, dealing exclusively in void[], and where all action 
is happening. That's where work is getting done, and also where assembly 
of various custom allocators happens. Best entry point for that is 
http://erdani.com/d/phobos-prerelease/std_experimental_allocator_building_blocks.html, 
which describes this layer's design and links to all untyped components.

* A statically-typed layer, which takes types from the user and gives 
back typed memory. There are two good entry points here: 
http://erdani.com/d/phobos-prerelease/std_experimental_allocator.html 
contains generic routines for creating and destroying typed objects 
using any untyped allocator: make, dispose, etc. There is also assembly 
at this level, i.e. deciding to use different heaps for shared vs. 
unshared data: 
http://erdani.com/d/phobos-prerelease/std_experimental_allocator_typed.html 
(this is particularly beautiful or awful, depending).

* A dynamicaly-typed layer that allows the user to swap allocators at 
runtime. This is embodied in IAllocator, CAllocatorImpl, theAllocator, 
and processAllocator.


Thanks in advance for reviewing this!

Andrei



More information about the Digitalmars-d mailing list