Shared keyword and the GC?

Sean Kelly sean at invisibleduck.org
Mon Oct 22 10:44:11 PDT 2012


On Oct 18, 2012, at 11:56 PM, Alex Rønne Petersen <alex at lycus.org> wrote:
> 
> I'm not really sure how this solves the problem of having pointers from a thread-local heap into the global heap and vice versa. Can you elaborate on that?
> 
> The problem is that even if you know whether a piece of memory is flagged shared, you cannot know if some arbitrary number of threads happen to have pointers to it and can thus mutate anything inside it while a thread-local collection is in progress.

Blocks flagged as shared would be completely ignored by the thread-local GC collection.  Since shared data may never reference unshared data, that should avoid anything being collected that's still referenced.  I hadn't thought about "immutable" though, which may turn out to be a problem.


More information about the Digitalmars-d mailing list