index.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta name="generator" content="rustdoc">
  7. <meta name="description" content="API documentation for the Rust `task` mod in crate `futures`.">
  8. <meta name="keywords" content="rust, rustlang, rust-lang, task">
  9. <title>futures::task - Rust</title>
  10. <link rel="stylesheet" type="text/css" href="../../normalize.css">
  11. <link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle">
  12. <link rel="stylesheet" type="text/css" href="../../dark.css">
  13. <link rel="stylesheet" type="text/css" href="../../main.css" id="themeStyle">
  14. <script src="../../storage.js"></script>
  15. </head>
  16. <body class="rustdoc mod">
  17. <!--[if lte IE 8]>
  18. <div class="warning">
  19. This old browser is unsupported and will most likely display funky
  20. things.
  21. </div>
  22. <![endif]-->
  23. <nav class="sidebar">
  24. <div class="sidebar-menu">&#9776;</div>
  25. <p class='location'>Module task</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li></ul></div><p class='location'><a href='../index.html'>futures</a></p><script>window.sidebarCurrent = {name: 'task', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div>
  26. </nav>
  27. <div class="theme-picker">
  28. <button id="theme-picker" aria-label="Pick another theme!">
  29. <img src="../../brush.svg" width="18" alt="Pick another theme!">
  30. </button>
  31. <div id="theme-choices"></div>
  32. </div>
  33. <script src="../../theme.js"></script>
  34. <nav class="sub">
  35. <form class="search-form js-only">
  36. <div class="search-container">
  37. <input class="search-input" name="search"
  38. autocomplete="off"
  39. placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
  40. type="search">
  41. </div>
  42. </form>
  43. </nav>
  44. <section id='main' class="content">
  45. <h1 class='fqn'><span class='in-band'>Module <a href='../index.html'>futures</a>::<wbr><a class="mod" href=''>task</a></span><span class='out-of-band'><span id='render-detail'>
  46. <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
  47. [<span class='inner'>&#x2212;</span>]
  48. </a>
  49. </span><a class='srclink' href='../../src/futures/task.rs.html#1-46' title='goto source code'>[src]</a></span></h1>
  50. <div class='docblock'><p>Tasks used to drive a future computation</p>
  51. <p>It's intended over time a particular operation (such as servicing an HTTP
  52. request) will involve many futures. This entire operation, however, can be
  53. thought of as one unit, as the entire result is essentially just moving
  54. through one large state machine.</p>
  55. <p>A &quot;task&quot; is the unit of abstraction for what is driving this state machine
  56. and tree of futures forward. A task is used to poll futures and schedule
  57. futures with, and has utilities for sharing data between tasks and handles
  58. for notifying when a future is ready. Each task also has its own set of
  59. task-local data generated by <code>task_local!</code>.</p>
  60. <p>Note that libraries typically should not manage tasks themselves, but rather
  61. leave that to event loops and other &quot;executors&quot; (see the <code>executor</code> module),
  62. or by using the <code>wait</code> method to create and execute a task directly on the
  63. current thread.</p>
  64. <p>More information about the task model can be found <a href="https://tokio.rs/docs/going-deeper-futures/futures-model/">online at tokio.rs</a>.</p>
  65. <h2 id="functions" class="section-header"><a href="#functions">Functions</a></h2>
  66. <p>There is an important bare function in this module: <code>current</code>. The
  67. <code>current</code> function returns a handle to the currently running task, panicking
  68. if one isn't present. This handle is then used to later notify the task that
  69. it's ready to make progress through the <code>Task::notify</code> method.</p>
  70. </div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
  71. <table>
  72. <tr class=' module-item'>
  73. <td><a class="struct" href="struct.AtomicTask.html"
  74. title='struct futures::task::AtomicTask'>AtomicTask</a></td>
  75. <td class='docblock-short'>
  76. <p>A synchronization primitive for task notification.</p>
  77. </td>
  78. </tr>
  79. <tr class=' module-item'>
  80. <td><a class="struct" href="struct.LocalKey.html"
  81. title='struct futures::task::LocalKey'>LocalKey</a></td>
  82. <td class='docblock-short'>
  83. <p>A key for task-local data stored in a future's task.</p>
  84. </td>
  85. </tr>
  86. <tr class=' module-item'>
  87. <td><a class="struct" href="struct.Task.html"
  88. title='struct futures::task::Task'>Task</a></td>
  89. <td class='docblock-short'>
  90. <p>A handle to a &quot;task&quot;, which represents a single lightweight &quot;thread&quot; of
  91. execution driving a future to completion.</p>
  92. </td>
  93. </tr>
  94. <tr class=' module-item'>
  95. <td><a class="struct" href="struct.UnparkEvent.html"
  96. title='struct futures::task::UnparkEvent'>UnparkEvent</a></td>
  97. <td class='docblock-short'>
  98. [<div class='stab deprecated'>Deprecated</div>] <p>A set insertion to trigger upon <code>unpark</code>.</p>
  99. </td>
  100. </tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
  101. <table>
  102. <tr class=' module-item'>
  103. <td><a class="trait" href="trait.EventSet.html"
  104. title='trait futures::task::EventSet'>EventSet</a></td>
  105. <td class='docblock-short'>
  106. [<div class='stab deprecated'>Deprecated</div>] <p>A concurrent set which allows for the insertion of <code>usize</code> values.</p>
  107. </td>
  108. </tr></table><h2 id='functions-1' class='section-header'><a href="#functions-1">Functions</a></h2>
  109. <table>
  110. <tr class=' module-item'>
  111. <td><a class="fn" href="fn.current.html"
  112. title='fn futures::task::current'>current</a></td>
  113. <td class='docblock-short'>
  114. <p>Returns a handle to the current task to call <code>notify</code> at a later date.</p>
  115. </td>
  116. </tr>
  117. <tr class=' module-item'>
  118. <td><a class="fn" href="fn.init.html"
  119. title='fn futures::task::init'>init</a><a title='unsafe function' href='#'><sup></sup></a></td>
  120. <td class='docblock-short'>
  121. <p>Initialize the <code>futures</code> task system.</p>
  122. </td>
  123. </tr>
  124. <tr class=' module-item'>
  125. <td><a class="fn" href="fn.with_unpark_event.html"
  126. title='fn futures::task::with_unpark_event'>with_unpark_event</a></td>
  127. <td class='docblock-short'>
  128. [<div class='stab deprecated'>Deprecated</div>] <p>For the duration of the given callback, add an &quot;unpark event&quot; to be
  129. triggered when the task handle is used to unpark the task.</p>
  130. </td>
  131. </tr></table></section>
  132. <section id='search' class="content hidden"></section>
  133. <section class="footer"></section>
  134. <aside id="help" class="hidden">
  135. <div>
  136. <h1 class="hidden">Help</h1>
  137. <div class="shortcuts">
  138. <h2>Keyboard Shortcuts</h2>
  139. <dl>
  140. <dt><kbd>?</kbd></dt>
  141. <dd>Show this help dialog</dd>
  142. <dt><kbd>S</kbd></dt>
  143. <dd>Focus the search field</dd>
  144. <dt><kbd></kbd></dt>
  145. <dd>Move up in search results</dd>
  146. <dt><kbd></kbd></dt>
  147. <dd>Move down in search results</dd>
  148. <dt><kbd></kbd></dt>
  149. <dd>Switch tab</dd>
  150. <dt><kbd>&#9166;</kbd></dt>
  151. <dd>Go to active search result</dd>
  152. <dt><kbd>+</kbd></dt>
  153. <dd>Expand all sections</dd>
  154. <dt><kbd>-</kbd></dt>
  155. <dd>Collapse all sections</dd>
  156. </dl>
  157. </div>
  158. <div class="infos">
  159. <h2>Search Tricks</h2>
  160. <p>
  161. Prefix searches with a type followed by a colon (e.g.
  162. <code>fn:</code>) to restrict the search to a given type.
  163. </p>
  164. <p>
  165. Accepted types are: <code>fn</code>, <code>mod</code>,
  166. <code>struct</code>, <code>enum</code>,
  167. <code>trait</code>, <code>type</code>, <code>macro</code>,
  168. and <code>const</code>.
  169. </p>
  170. <p>
  171. Search functions by type signature (e.g.
  172. <code>vec -> usize</code> or <code>* -> vec</code>)
  173. </p>
  174. </div>
  175. </div>
  176. </aside>
  177. <script>
  178. window.rootPath = "../../";
  179. window.currentCrate = "futures";
  180. </script>
  181. <script src="../../main.js"></script>
  182. <script defer src="../../search-index.js"></script>
  183. </body>
  184. </html>