struct.AtomicTask.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 `AtomicTask` struct in crate `futures`.">
  8. <meta name="keywords" content="rust, rustlang, rust-lang, AtomicTask">
  9. <title>futures::task::AtomicTask - 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 struct">
  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'>Struct AtomicTask</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.new">new</a><a href="#method.register">register</a><a href="#method.register_task">register_task</a><a href="#method.notify">notify</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Default">Default</a><a href="#impl-Debug">Debug</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a></div></div><p class='location'><a href='../index.html'>futures</a>::<wbr><a href='index.html'>task</a></p><script>window.sidebarCurrent = {name: 'AtomicTask', ty: 'struct', 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'>Struct <a href='../index.html'>futures</a>::<wbr><a href='index.html'>task</a>::<wbr><a class="struct" href=''>AtomicTask</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_impl/atomic_task.rs.html#27-30' title='goto source code'>[src]</a></span></h1>
  50. <pre class='rust struct'>pub struct AtomicTask { /* fields omitted */ }</pre><div class='docblock'><p>A synchronization primitive for task notification.</p>
  51. <p><code>AtomicTask</code> will coordinate concurrent notifications with the consumer
  52. potentially &quot;updating&quot; the underlying task to notify. This is useful in
  53. scenarios where a computation completes in another thread and wants to
  54. notify the consumer, but the consumer is in the process of being migrated to
  55. a new logical task.</p>
  56. <p>Consumers should call <code>register</code> before checking the result of a computation
  57. and producers should call <code>notify</code> after producing the computation (this
  58. differs from the usual <code>thread::park</code> pattern). It is also permitted for
  59. <code>notify</code> to be called <strong>before</strong> <code>register</code>. This results in a no-op.</p>
  60. <p>A single <code>AtomicTask</code> may be reused for any number of calls to <code>register</code> or
  61. <code>notify</code>.</p>
  62. <p><code>AtomicTask</code> does not provide any memory ordering guarantees, as such the
  63. user should use caution and use other synchronization primitives to guard
  64. the result of the underlying computation.</p>
  65. </div>
  66. <h2 id='methods' class='small-section-header'>
  67. Methods<a href='#methods' class='anchor'></a>
  68. </h2>
  69. <h3 id='impl' class='impl'><span class='in-band'><code>impl <a class="struct" href="../../futures/task/struct.AtomicTask.html" title="struct futures::task::AtomicTask">AtomicTask</a></code><a href='#impl' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/futures/task_impl/atomic_task.rs.html#137-279' title='goto source code'>[src]</a></span></h3>
  70. <div class='impl-items'><h4 id='method.new' class="method"><span id='new.v' class='invisible'><code>pub fn <a href='#method.new' class='fnname'>new</a>() -&gt; <a class="struct" href="../../futures/task/struct.AtomicTask.html" title="struct futures::task::AtomicTask">AtomicTask</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/futures/task_impl/atomic_task.rs.html#139-148' title='goto source code'>[src]</a></span></h4>
  71. <div class='docblock'><p>Create an <code>AtomicTask</code> initialized with the given <code>Task</code></p>
  72. </div><h4 id='method.register' class="method"><span id='register.v' class='invisible'><code>pub fn <a href='#method.register' class='fnname'>register</a>(&amp;self)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/futures/task_impl/atomic_task.rs.html#153-155' title='goto source code'>[src]</a></span></h4>
  73. <div class='docblock'><p>Registers the current task to be notified on calls to <code>notify</code>.</p>
  74. <p>This is the same as calling <code>register_task</code> with <code>task::current()</code>.</p>
  75. </div><h4 id='method.register_task' class="method"><span id='register_task.v' class='invisible'><code>pub fn <a href='#method.register_task' class='fnname'>register_task</a>(&amp;self, task: <a class="struct" href="../../futures/task/struct.Task.html" title="struct futures::task::Task">Task</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/futures/task_impl/atomic_task.rs.html#172-243' title='goto source code'>[src]</a></span></h4>
  76. <div class='docblock'><p>Registers the provided task to be notified on calls to <code>notify</code>.</p>
  77. <p>The new task will take place of any previous tasks that were registered
  78. by previous calls to <code>register</code>. Any calls to <code>notify</code> that happen after
  79. a call to <code>register</code> (as defined by the memory ordering rules), will
  80. notify the <code>register</code> caller's task.</p>
  81. <p>It is safe to call <code>register</code> with multiple other threads concurrently
  82. calling <code>notify</code>. This will result in the <code>register</code> caller's current
  83. task being notified once.</p>
  84. <p>This function is safe to call concurrently, but this is generally a bad
  85. idea. Concurrent calls to <code>register</code> will attempt to register different
  86. tasks to be notified. One of the callers will win and have its task set,
  87. but there is no guarantee as to which caller will succeed.</p>
  88. </div><h4 id='method.notify' class="method"><span id='notify.v' class='invisible'><code>pub fn <a href='#method.notify' class='fnname'>notify</a>(&amp;self)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/futures/task_impl/atomic_task.rs.html#248-278' title='goto source code'>[src]</a></span></h4>
  89. <div class='docblock'><p>Notifies the task that last called <code>register</code>.</p>
  90. <p>If <code>register</code> has not been called yet, then this does nothing.</p>
  91. </div></div>
  92. <h2 id='implementations' class='small-section-header'>
  93. Trait Implementations<a href='#implementations' class='anchor'></a>
  94. </h2>
  95. <h3 id='impl-Default' class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="../../futures/task/struct.AtomicTask.html" title="struct futures::task::AtomicTask">AtomicTask</a></code><a href='#impl-Default' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/futures/task_impl/atomic_task.rs.html#281-285' title='goto source code'>[src]</a></span></h3>
  96. <div class='impl-items'><h4 id='method.default' class="method"><span id='default.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default' class='fnname'>default</a>() -&gt; Self</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/futures/task_impl/atomic_task.rs.html#282-284' title='goto source code'>[src]</a></span></h4>
  97. <div class='docblock'><p>Returns the &quot;default value&quot; for a type. <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default">Read more</a></p>
  98. </div></div><h3 id='impl-Debug' class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../futures/task/struct.AtomicTask.html" title="struct futures::task::AtomicTask">AtomicTask</a></code><a href='#impl-Debug' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/futures/task_impl/atomic_task.rs.html#287-291' title='goto source code'>[src]</a></span></h3>
  99. <div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, fmt: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/futures/task_impl/atomic_task.rs.html#288-290' title='goto source code'>[src]</a></span></h4>
  100. <div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
  101. </div></div><h3 id='impl-Send' class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../futures/task/struct.AtomicTask.html" title="struct futures::task::AtomicTask">AtomicTask</a></code><a href='#impl-Send' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/futures/task_impl/atomic_task.rs.html#293' title='goto source code'>[src]</a></span></h3>
  102. <div class='impl-items'></div><h3 id='impl-Sync' class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../futures/task/struct.AtomicTask.html" title="struct futures::task::AtomicTask">AtomicTask</a></code><a href='#impl-Sync' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/futures/task_impl/atomic_task.rs.html#294' title='goto source code'>[src]</a></span></h3>
  103. <div class='impl-items'></div></section>
  104. <section id='search' class="content hidden"></section>
  105. <section class="footer"></section>
  106. <aside id="help" class="hidden">
  107. <div>
  108. <h1 class="hidden">Help</h1>
  109. <div class="shortcuts">
  110. <h2>Keyboard Shortcuts</h2>
  111. <dl>
  112. <dt><kbd>?</kbd></dt>
  113. <dd>Show this help dialog</dd>
  114. <dt><kbd>S</kbd></dt>
  115. <dd>Focus the search field</dd>
  116. <dt><kbd>↑</kbd></dt>
  117. <dd>Move up in search results</dd>
  118. <dt><kbd>↓</kbd></dt>
  119. <dd>Move down in search results</dd>
  120. <dt><kbd>↹</kbd></dt>
  121. <dd>Switch tab</dd>
  122. <dt><kbd>&#9166;</kbd></dt>
  123. <dd>Go to active search result</dd>
  124. <dt><kbd>+</kbd></dt>
  125. <dd>Expand all sections</dd>
  126. <dt><kbd>-</kbd></dt>
  127. <dd>Collapse all sections</dd>
  128. </dl>
  129. </div>
  130. <div class="infos">
  131. <h2>Search Tricks</h2>
  132. <p>
  133. Prefix searches with a type followed by a colon (e.g.
  134. <code>fn:</code>) to restrict the search to a given type.
  135. </p>
  136. <p>
  137. Accepted types are: <code>fn</code>, <code>mod</code>,
  138. <code>struct</code>, <code>enum</code>,
  139. <code>trait</code>, <code>type</code>, <code>macro</code>,
  140. and <code>const</code>.
  141. </p>
  142. <p>
  143. Search functions by type signature (e.g.
  144. <code>vec -> usize</code> or <code>* -> vec</code>)
  145. </p>
  146. </div>
  147. </div>
  148. </aside>
  149. <script>
  150. window.rootPath = "../../";
  151. window.currentCrate = "futures";
  152. </script>
  153. <script src="../../main.js"></script>
  154. <script defer src="../../search-index.js"></script>
  155. </body>
  156. </html>