VariantPointer

Lass Safin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Apr 20 09:08:32 PDT 2016


On Wednesday, 20 April 2016 at 14:36:54 UTC, Nordlöw wrote:
> On Wednesday, 20 April 2016 at 13:41:27 UTC, Nordlöw wrote:
>> At
>>
>> https://github.com/nordlow/phobos-next/blob/master/src/variant_pointer.d
>
> Further:
>
> What to do with fact that the GC will fail to scan 
> VariantPointers?
>
> Can the GC be tweaked to mask out the type bits before scanning?

core.memory.GC.setAttr can set attributes for a block of memory, 
with which you can set the attribute NO_SCAN, which as it 
implies, forces that no scan be done in the particular block of 
memory.
This can be used to insure that the GC doesn't mark blocks not 
alive as alive.
Then, use GC.addRoot with the pointer to your actual data, with 
the typeinfo bits cleared, passed as a parameter, to add an 
internal pointer inside the GC itself to the data, so that is 
considered live until removeRoot is called on the same pointer. 
addRoot and removeRoot can be put into this and ~this, 
respectively.


More information about the Digitalmars-d-learn mailing list