Make vtkLogger::ThreadName a thread_local variable
vtkLogger::Init()
resets the ThreadName
of the calling thread using the last used value of the static variable vtkLogger::ThreadName
.
This means that if multiple threads call vtkLogger::SetThreadName(ThreadName)
and then any of them calls vtkLogger::Init()
it will mess up its name.
The attached example fails in current master.
This issue was found by naming multiple threads and then later calling vtkPythonInterpreter::Initialize()
which internally calls vtkLogger::Init()
.
Making the global vtkLogger::ThreadName
static thread_local
instead of just static
resolves the issue.
Visual Studio compiler emits
error C2492: 'vtkLogger::ThreadName': data with thread storage duration may not have dll interface
when combining static
with thread_local
, so the variable has been moved from the header file to the internal detail
namespace.
Edited by Christos Tsolakis