Threads

Intel® Threading Building Blocks (Intel® TBB) provides a wrapper around the platform's native threads, based upon the N3000 working draft for C++11. Using this wrapper has two benefits:

  • It makes threaded code portable across platforms.

  • It eases later migration to ISO C++11 threads.

The library defines the wrapper in namespace std, not namespace tbb, as explained in Section Namespace.

The significant departures from N3000 are shown in the table below.

Differences Between N3000 and Intel® TBB Thread Class

N3000

Intel® TBB

template<class Rep, class Period> std::this_thread::sleep_for(

const chrono::duration<Rep, Period>& rel_time)

std::this_thread::sleep_for( tick_count::interval_t )

rvalue reference parameters

Parameter changed to plain value, or function removed, as appropriate.

constructor for std::thread takes arbitrary number of arguments.

constructor for std::thread takes 0-3 arguments.

The other changes are for compatibility with the current C++ standard or Intel® TBB. For example, constructors that have an arbitrary number of arguments require the variadic template features of C++11.

Caution

Threads are heavy weight entities on most systems, and running too many threads on a system can seriously degrade performance. Consider using a task based solution instead if practical.

For more complete information about compiler optimizations, see our Optimization Notice.