An important pull request: accessing shared affix for immutable data

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 14 03:14:59 PST 2016


On 02/14/2016 03:08 AM, Sönke Ludwig wrote:
> For them to work natively, the lifetime of the allocated memory block
> and that of the reference count must be separate.

Not necessarily. C++ makes this work for make_shared by keeping the 
memory allocated around (but not the object) until the last weak ref 
goes away.

We can do the same, but we also have a better alternative. Most of our 
allocators support shrink-in-place. For now I haven't exposed it as a 
primitive but that's short work. When the object goes away we can shrink 
memory in place to only the length of the metadata.

Overall: I also think weak refs should be supported, but I know they can 
be tacked on later.


Andrei



More information about the Digitalmars-d mailing list