You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
5.4 KiB

  1. <!DOCTYPE html
  2. PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  3. <!-- saved from url=(0014)about:internet -->
  4. <html xmlns:MSHelp="http://www.microsoft.com/MSHelp/" lang="en-us" xml:lang="en-us"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <meta name="DC.Type" content="reference">
  6. <meta name="DC.Title" content="Threads">
  7. <meta name="DC.subject" content="Threads">
  8. <meta name="keywords" content="Threads">
  9. <meta name="DC.Relation" scheme="URI" content="../reference/reference.htm">
  10. <meta name="DC.Relation" scheme="URI" content="../reference/threads/thread_cls.htm">
  11. <meta name="DC.Relation" scheme="URI" content="../reference/threads/thread_id.htm">
  12. <meta name="DC.Relation" scheme="URI" content="../reference/threads/this_thread_namespace.htm">
  13. <meta name="DC.Relation" scheme="URI" content="general_conventions/namespaces.htm">
  14. <meta name="DC.Format" content="XHTML">
  15. <meta name="DC.Identifier" content="threads">
  16. <meta name="DC.Language" content="en-US">
  17. <link rel="stylesheet" type="text/css" href="../intel_css_styles.css">
  18. <title>Threads</title>
  19. </head>
  20. <body id="threads">
  21. <!-- ==============(Start:NavScript)================= -->
  22. <script src="..\NavScript.js" language="JavaScript1.2" type="text/javascript"></script>
  23. <script language="JavaScript1.2" type="text/javascript">WriteNavLink(1);</script>
  24. <!-- ==============(End:NavScript)================= -->
  25. <a name="threads"><!-- --></a>
  26. <h1 class="topictitle1">Threads</h1>
  27. <div>
  28. <div class="section">
  29. <p>Intel&reg; Threading Building Blocks (Intel&reg; TBB)
  30. provides a wrapper around the platform's native threads, based upon the N3000
  31. working draft for C++11. Using this wrapper has two benefits:
  32. </p>
  33. <ul type="disc">
  34. <li>
  35. <p>It makes threaded code portable across
  36. platforms.
  37. </p>
  38. </li>
  39. <li>
  40. <p>It eases later migration to ISO C++11
  41. threads.
  42. </p>
  43. </li>
  44. </ul>
  45. <p>The library defines the wrapper in namespace
  46. <samp class="codeph">std</samp>, not namespace
  47. <samp class="codeph">tbb</samp>, as explained in Section Namespace.
  48. </p>
  49. <p>The significant departures from N3000 are shown in
  50. the table below.
  51. </p>
  52. <div class="tablenoborder"><a name="tbl36"><!-- --></a><table cellpadding="4" summary="" id="tbl36" width="100%" frame="hsides" border="1" rules="all"><caption><span class="tablecap">Differences Between N3000 and Intel&reg; TBB
  53. Thread Class</span></caption>
  54. <thead align="left">
  55. <tr>
  56. <th class="cellrowborder" valign="top" width="NaN%" id="d123197e64">
  57. <p>N3000
  58. </p>
  59. </th>
  60. <th class="row-nocellborder" valign="top" width="NaN%" id="d123197e70">
  61. <p>Intel&reg; TBB
  62. </p>
  63. </th>
  64. </tr>
  65. </thead>
  66. <tbody>
  67. <tr>
  68. <td class="cellrowborder" valign="top" width="NaN%" headers="d123197e64 ">
  69. <p><samp class="codeph">template&lt;class Rep, class
  70. Period&gt; std::this_thread::sleep_for(</samp>
  71. </p>
  72. <p><samp class="codeph">const chrono::duration&lt;Rep,
  73. Period&gt;&amp; rel_time)</samp>
  74. </p>
  75. </td>
  76. <td class="row-nocellborder" valign="top" width="NaN%" headers="d123197e70 ">
  77. <p><samp class="codeph">std::this_thread::sleep_for(
  78. tick_count::interval_t )</samp>
  79. </p>
  80. </td>
  81. </tr>
  82. <tr>
  83. <td class="cellrowborder" valign="top" width="NaN%" headers="d123197e64 ">
  84. <p>rvalue reference parameters
  85. </p>
  86. </td>
  87. <td class="row-nocellborder" valign="top" width="NaN%" headers="d123197e70 ">
  88. <p>Parameter changed to plain value, or
  89. function removed, as appropriate.
  90. </p>
  91. </td>
  92. </tr>
  93. <tr>
  94. <td class="cellrowborder" valign="top" width="NaN%" headers="d123197e64 ">
  95. <p>constructor for
  96. <samp class="codeph">std::thread</samp> takes arbitrary number of
  97. arguments.
  98. </p>
  99. </td>
  100. <td class="row-nocellborder" valign="top" width="NaN%" headers="d123197e70 ">
  101. <p>constructor for
  102. <samp class="codeph">std::thread</samp> takes 0-3 arguments.
  103. </p>
  104. </td>
  105. </tr>
  106. </tbody>
  107. </table>
  108. </div>
  109. <p>The other changes are for compatibility with the
  110. current C++ standard or Intel&reg; TBB. For example, constructors that have an
  111. arbitrary number of arguments require the variadic template features of C++11.
  112. </p>
  113. <div class="Note"><h3 class="NoteTipHead">
  114. Caution</h3>
  115. <p>Threads are heavy weight entities on most
  116. systems, and running too many threads on a system can seriously degrade
  117. performance. Consider using a task based solution instead if practical.
  118. </p>
  119. </div>
  120. </div>
  121. </div>
  122. <div class="familylinks">
  123. <div class="parentlink"><strong>Parent topic:</strong>&nbsp;<a href="../reference/reference.htm">Intel&reg; Threading Building Blocks Reference Manual</a></div>
  124. </div>
  125. <div class="See Also">
  126. <ul class="ullinks">
  127. <li class="ulchildlink"><a href="../reference/threads/thread_cls.htm">thread Class</a><br>
  128. </li>
  129. <li class="ulchildlink"><a href="../reference/threads/thread_id.htm">thread::id</a><br>
  130. </li>
  131. <li class="ulchildlink"><a href="../reference/threads/this_thread_namespace.htm">this_thread Namespace</a><br>
  132. </li>
  133. </ul>
  134. <h2>See Also</h2>
  135. <div class="linklist">
  136. <div><a href="general_conventions/namespaces.htm">Namespaces, std Namespace
  137. </a></div></div>
  138. </div>
  139. </body>
  140. </html>