You just weren't lazy enough (that incomplete piece of code might have been omitted).
![smiley [:-)]](/isn/Community/en-US/emoticons/emotion-1.gif)
But what is tbb_thread doing in TBB as a non-internal object without added value (just a stand-in for the future std::thread)? For example, in Java, a Thread by default is not isDaemon(), and a program will continue executing while any non-daemon threads remain. The only basic feature I see Thread lacking is a direct implementation of the preferred pattern to stop a thread, requiring the use of an external variable instead.
And isn't TBB all about not using raw threads? Just publishing tbb_thread seems enough validation for some people to want to use it. Shouldn't anyone wanting to use legacy multithreading code also be required to use legacy means to do so? Who is really afraid of: "CAUTION: Threads are heavy weight on most systems, and running too many threads on a system can seriously degrade performance. Consider using a task based solution instead if practical." (buried somewhere at the end of the introduction in the reference)?
Where I see a remaining need for raw threads is to get around worker thread unavailability, but that should be solved another way, for example:
/* somewhere inside execute() */ { tbb::task::scoped_disruption anonymous;
// with default constructor argument tbb::task::self()
/* something that may block */ { ...
}
}
This would be differentiatable to provide hints about expected total duration and likelihood and granularity of the disruption, so that the scheduler can do something smart about reusing that hardware thread, possibly based on gathered statistics, so maybe the disruption should be identified somehow for use in a hash table (a macro could pass __FILE__ and __LINE__). scoped_disruption might decide that the arguments are not significant enough to offset the cost of the associated administration, and maybe task affinity could be leveraged to schedule a group of tasks locally to avoid administration bottlenecks.
These were 3 questions (why no added value, why there at all, what else).