関数に静的な変数がありますが、スレッドごとに静的にしたいと考えています。
各スレッドが独自のクラス インスタンスのコピーを持つように、C++ クラスにメモリを割り当てるにはどうすればよいですか?
AnotherClass::threadSpecificAction()
{
// How to allocate this with thread local storage?
static MyClass *instance = new MyClass();
instance->doSomething();
}
これはLinux上にあります。私は C++0x を使用していません。これは gcc v3.4.6 です。