In Threading Building Blocks (TBB), if I initialize 2 task schedulers within the same scope, the argument of the second initialization will be ignored unless the argument of the first initialization is deferred. In order to avoid any conflicts, I would like to find out if a task scheduler has been initialized earlier in my program. Is there a way to do it? If so, what was the argument to that?
You may want to consider tbb::this_task_arena::current_thread_index()
and tbb::this_task_arena::max_concurrency()
functions.
The tbb::this_task_arena::current_thread_index()
function returns "tbb::task_arena::not_initialized
if the thread has not yet initialized the task scheduler." (documentation link).
If the task scheduler is already initialized you can obtain the requested number of threads with the tbb::this_task_arena::max_concurrency()
function. However, you cannot get the stack size used during the previous task scheduler initialization.