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.

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