My application uses multimedia timers to process video from hardware devices as well as the display.
The structure of the code to support a multimedia timer requires a static callback procedure, as a hook in point, to the system generated multimedia timer. In my situation this is simply the static function in my class. I make sure to initialize the timer with "this" as the user defined data. The timer is called in the context of the multimedia timer thread, and my code will reconstruct "this" as a back pointer to the original instance of the class that caused the timer to be used.
During the callback, when I use parallel_reduce, TBB complains about an initialization problem. Basically, If I understand the docs correctly, this situation constitutes an isolated task, where the parent has no knowledge of TBB. I would like to know how to use parallel_reduce in combination with an isolated task. It seems like I have no chance of getting to initialize TBB in the multimedia timer.
The specific error is --------------------------- Microsoft Visual C++ Debug Library --------------------------- Debug Assertion Failed!
As long as there is at least one long-lived task_scheduler_init somewhere in the process (like in main()), it is cheap enough to have another one, not necessarily unique, on the stack of any thread that may not yet be known to TBB (like a local variable in the callback).
Also to better support such situations, a new version of TBB (to be released later this year) will have automatic initialization of the TBB scheduler. The effect of automatic intialization will be as if a task_scheduler_init object was created inside the first call toa parallel algorithm in a thread, and was kept alive till the thread shuts down.