In my application run several regular windows threads. 2 of these threads create in thier constructor 2 task scheduler object (each one of them has one task scheduler object).
Iuse the parallel_for function in several places in my application.The useis only on the above 2 threads.
Sometimes i get the following message (probably during the activation of the first parallel_for). Can you guess why it happans? what could fix this problem?
The specific error is
Microsoft Visual C++ Debug Library
Debug Assertion Failed!
Thread has not activated a task_scheduler_init object?
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
I assume that, like tbb_thread or any other thread objects that I know, these thread objects are (obviously) not constructed inside the thread that they manage? But you really have to have a task_scheduler_init in that thread itself, so if you want to hide its use, do so in a function that is passed to super, thathas a local/automatic task_scheduler_init on the thread's stack, and that then forwards its arguments to the argument function of the overridden thread object.
If there's anything that by definition qualifies for a new FAQ entry, it's these task_scheduler_init issues... :-)