diff --git a/src/tl/tl/tlThreads.h b/src/tl/tl/tlThreads.h index 1f4a7a870..2fbd7204d 100644 --- a/src/tl/tl/tlThreads.h +++ b/src/tl/tl/tlThreads.h @@ -228,7 +228,6 @@ protected: } }; -// TODO: this is the non-threaded dummy implementation template class ThreadStorage : public ThreadStorageBase @@ -253,7 +252,11 @@ public: void setLocalData (const T &data) { - add (new ThreadStorageHolder (new T (data))); + if (hasLocalData ()) { + localData () = data; + } else { + add (new ThreadStorageHolder (new T (data))); + } } }; diff --git a/src/tl/unit_tests/tlThreadsTests.cc b/src/tl/unit_tests/tlThreadsTests.cc index c5a65d4a5..57d2285a9 100644 --- a/src/tl/unit_tests/tlThreadsTests.cc +++ b/src/tl/unit_tests/tlThreadsTests.cc @@ -229,7 +229,7 @@ TEST(3) MyThread3 my_thread; my_thread.start (); // While we start the loop inside the thread we run it outside. Since - // the counter is TLS, both loops will to the same but with different data. + // the counter is TLS, both loops will do the same but with different data. // A mutex is not involved. EXPECT_EQ (my_thread.do_run (9999999), 9999999); my_thread.wait ();