Skip to content
Snippets Groups Projects
Commit 81a5b257 authored by Ken Martin's avatar Ken Martin
Browse files

try another fix for tsan condition variable

I think the old code was fine but tsan can
have false positives with some atomic types
and race conditions so try another fix
parent c5272055
No related branches found
No related tags found
No related merge requests found
......@@ -23,8 +23,8 @@ VTK_THREAD_RETURN_TYPE vtkTestCondVarThread( void* arg )
{
if ( threadId == 0 )
{
td->Done = 0;
td->Lock->Lock();
td->Done = 0;
cout << "Thread " << ( threadId + 1 ) << " of " << threadCount << " initializing.\n";
cout.flush();
td->Lock->Unlock();
......@@ -61,10 +61,22 @@ VTK_THREAD_RETURN_TYPE vtkTestCondVarThread( void* arg )
else
{
// Wait for thread 0 to initialize... Ugly but effective
while ( td->Done < 0 )
bool done = false;
do
{
vtksys::SystemTools::Delay( 200 ); // 0.2 s between checking
td->Lock->Lock();
if (td->Done)
{
done = true;
td->Lock->Unlock();
}
else
{
td->Lock->Unlock();
vtksys::SystemTools::Delay( 200 ); // 0.2 s between checking
}
}
while (!done);
// Wait for the condition and then note we were signaled.
// This part looks like a Hansen Monitor:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment