Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Penunuri__David
Beginner
34 Views

Diagnostic console output

I am putting some diagnostic console output statements in my code which uses TBB like

cout << "blah..blah..blah" << endl;

It is hard to read the results because the different threads are mixing their output on the console.

HOW DO I FIX THIS (IGNORING FOR THE MOMENT THE PERFORMANCE IMPACT)?

I tried to search the forum with no luck.  I know in pthreads I could lock/unlock a section of code using a mutex.  It is not clear how to do this in TBB.

0 Kudos
1 Reply
Nikita_P_Intel
Employee
34 Views

Hi David,

you can just set the number of threads to 1 for debugging purpose via tbb::task_scheduler_init(1), or use one of tbb::mutex classes to surround and protect your output.

-- Nikita