Shared keyword and the GC?
Sean Kelly
sean at invisibleduck.org
Thu Oct 18 11:54:08 PDT 2012
On Oct 18, 2012, at 11:48 AM, Jacob Carlborg <doob at me.com> wrote:
> On 2012-10-18 20:26, Sean Kelly wrote:
>
>> Well, the problem is more that a variable can be cast to shared after instantiation, so to allow thread-local collections we'd have to make cast(shared) set a flag on the memory block to indicate that it's shared, and vice-versa for unshared. Then when a thread terminates, all blocks not flagged as shared would be finalized, leaving the shared blocks alone. Then any pool from the terminated thread containing a shared block would have to be merged into the global heap instead of released to the OS.
>
> Or move the shared data to the global heap when it's casted. Don't know that's best. This way all data in a give pool will be truly thread local.
And back down to a local pool when shared is cast away. Assuming the block is even movable. I agree that this would be the most efficient use of memory, but I don't know that it's feasible.
More information about the Digitalmars-d
mailing list