Shared keyword and the GC?

Jacob Carlborg doob at me.com
Thu Oct 18 11:48:18 PDT 2012


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.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list