Shared keyword and the GC?
Jacob Carlborg
doob at me.com
Fri Oct 19 00:42:53 PDT 2012
On 2012-10-19 03:06, Michel Fortin wrote:
> All this is nice, but what is the owner thread for immutable data?
> Because immutable is always implicitly shared, all your strings and
> everything else that is immutable is thus "shared" and must be tracked
> by the global heap's collector and can never be handled by a
> thread-local collector. Even if most immutable data never leaves the
> thread it was allocated in, there's no way you can know.
>
> I don't think per-thread GCs will work very well without support for
> immutable data, an for that you need to have a distinction between
> immutable and shared immutable (just like you have with mutable data). I
> complained about this almost three years ago when the semantics of
> shared were being defined, but it got nowhere. Quoting Walter at the time:
Would it be any difference if the immutable data was collected from a
different collector than the shared or thread local?
In this case I guess the collector wouldn't try to make a difference
between shared and non-shared immutable data.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list