D-Programming-Language/phobos — pull request #1302 by someboddy (2013-05-24 21:32:16+00:00)
Title: fix issue 10165 - No syntax to create thread-local shared variables

http://d.puremagic.com/issues/show_bug.cgi?id=10165

The new `std.typecons.Shared` allows the declaration of thread-local
shared variables:

```D
static class Foo
{
static shared(Foo) a;
static Shared!Foo b;
}

//Initialize both a and b in another thread:
auto thread = new core.thread.Thread({
Foo.a = new shared(Foo)();
Foo.b = new shared(Foo)();
});
thread.start();
thread.join();

//a is static shared, so there is one Foo.a for all threads.
assert(Foo.a !is null);
//b is just static, so this thread has a different Foo.a.
assert(Foo.b is null);
```

This is a problem I encountered while designing the `shared` version of the low lock singleton for my `std.idioms` library - there is some forum discussion about it here: http://forum.dlang.org/thread/fofbrlqruxbevnxchxdp@forum.dlang.org?page=5#post-knnqp6:242l7h:241:40digitalmars.com