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

Walter Bright walter at digitalmars.com
Thu May 12 20:05:13 PDT 2011



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.


More information about the phobos mailing list