What's the go with the GC these days?

Steven Schveighoffer schveiguy at gmail.com
Tue Jan 8 14:21:23 UTC 2019


On 1/7/19 4:57 PM, Neia Neutuladh wrote:
> On Mon, 07 Jan 2019 13:06:22 -0800, H. S. Teoh wrote:
>> Hmph, good point.  That sux. :-(  I suppose that's where copying/moving
>> the object comes in -- migrate it to a different pool somehow so that we
>> can avoid stop-the-world.
> 
> class Node
> {
>    enum Type { leaf, intermediate }
>    Type type;
>    union { Node child; ulong data; }
> }
> auto node = new Node;
> node.type = Node.Type.leaf;
> node.data = cast(ulong)cast(void*)node;
> 
> How do you copy this?

You copy the memory, then update the references to that memory.

Or you make the user explicitly copy, and disallow the cast.

> Pinning avoids those problems, but it still involves scanning memory as if
> doing a collection.

Even if you pin, if you cast the above from shared to unshared, you then 
have made it so the thread-local pool cannot be scanned independently.

If we get thread-local pools, and all scans have to be done on all 
thread local pools along with the shared pool, we haven't gained anything.

-Steve


More information about the Digitalmars-d mailing list