mirror of https://github.com/KLayout/klayout.git
Fixed non-Qt thread-local storage implementation: needs to reuse holder object when using 'setLocalData'
This commit is contained in:
parent
f2b91997f0
commit
baa92d4455
|
|
@ -228,7 +228,6 @@ protected:
|
|||
}
|
||||
};
|
||||
|
||||
// TODO: this is the non-threaded dummy implementation
|
||||
template <class T>
|
||||
class ThreadStorage
|
||||
: public ThreadStorageBase
|
||||
|
|
@ -253,7 +252,11 @@ public:
|
|||
|
||||
void setLocalData (const T &data)
|
||||
{
|
||||
add (new ThreadStorageHolder<T> (new T (data)));
|
||||
if (hasLocalData ()) {
|
||||
localData () = data;
|
||||
} else {
|
||||
add (new ThreadStorageHolder<T> (new T (data)));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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 ();
|
||||
|
|
|
|||
Loading…
Reference in New Issue