std.functional.memoize : thread local or __gshared memoization?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Wed May 24 17:19:32 PDT 2017


On Wednesday, May 24, 2017 16:56:49 Timothee Cour via Digitalmars-d wrote:
> I could look at source to figure it out but others might wonder and I
> couldn't find it in the docs in
> https://dlang.org/library/std/functional/memoize.html whether memoize
> works per thread (thread local) or globally (__gshared)

Definitely thread-local, and there would be problems if it were shared,
since for that to work properly, it would really need to be given either
shared data or data that implicitly converted to shared. And while __gshared
might skirt the compiler yelling at you, it would have the same issues; it's
just that the compiler wouldn't be yelling at you about them, so it would be
harder to catch them and more likely that you'd get weird,
hard-to-track-down bugs.

- Jonathan M Davis



More information about the Digitalmars-d mailing list