[phobos] Gcx: Would we ever want more than one?

David Simcha dsimcha at gmail.com
Thu May 12 20:14:46 PDT 2011


On 5/12/2011 11:05 PM, Walter Bright wrote:
>
>
> On 5/12/2011 8:01 PM, David Simcha wrote:
>> I'm looking to get rid of the global malloc lock for small memory 
>> allocations.  A major barrier to pulling this off within the current 
>> GC design is the fact that Gcx is a struct, which suggests the 
>> possibility of having more than one instance and makes it more 
>> difficult to create thread-local objects.  Is there any reason why we 
>> would ever want more than one garbage collector instance?  If not, 
>> why is Gcx a struct instead of just a bunch of __gshared variables?
>>
>
> You can get multiple Gcx instances when you're connecting DLL 
> instances together. That's why the druntime allows you the means to 
> pick one.
>
> Also, grouping them together in a single struct is good encapsulation 
> practice, rather than a random distributed collection of globals.
>

Crap.  This means I'm going to have to get creative and figure out a way 
to get storage that's local to both a Gcx instance and a thread.  
Definitely do-able, but not pretty.



More information about the phobos mailing list