123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `Notify` trait in crate `futures`."><meta name="keywords" content="rust, rustlang, rust-lang, Notify"><title>futures::executor::Notify - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script src="../../storage.js"></script></head><body class="rustdoc trait"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><p class='location'>Trait Notify</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.notify">notify</a></div><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.clone_id">clone_id</a><a href="#method.drop_id">drop_id</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='../index.html'>futures</a>::<wbr><a href='index.html'>executor</a></p><script>window.sidebarCurrent = {name: 'Notify', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='in-band'>Trait <a href='../index.html'>futures</a>::<wbr><a href='index.html'>executor</a>::<wbr><a class="trait" href=''>Notify</a></span><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../../src/futures/task_impl/mod.rs.html#390-444' title='goto source code'>[src]</a></span></h1><div class="docblock type-decl"><pre class='rust trait'>pub trait Notify: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> {
- fn <a href='#tymethod.notify' class='fnname'>notify</a>(&self, id: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>);
- fn <a href='#method.clone_id' class='fnname'>clone_id</a>(&self, id: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a> { ... }
- <div class='item-spacer'></div> fn <a href='#method.drop_id' class='fnname'>drop_id</a>(&self, id: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) { ... }
- }</pre></div><div class='docblock'><p>A trait which represents a sink of notifications that a future is ready to
- make progress.</p>
- <p>This trait is provided as an argument to the <code>Spawn::*_notify</code> family of
- functions. It's transitively used as part of the <code>Task::notify</code> method to
- internally deliver notifications of readiness of a future to move forward.</p>
- <p>An instance of <code>Notify</code> has one primary method, <code>notify</code>, which is given a
- contextual argument as to what's being notified. This contextual argument is
- <em>also</em> provided to the <code>Spawn::*_notify</code> family of functions and can be used
- to reuse an instance of <code>Notify</code> across many futures.</p>
- <p>Instances of <code>Notify</code> must be safe to share across threads, and the methods
- be invoked concurrently. They must also live for the <code>'static</code> lifetime,
- not containing any stack references.</p>
- </div>
- <h2 id='required-methods' class='small-section-header'>
- Required Methods<a href='#required-methods' class='anchor'></a>
- </h2>
- <div class='methods'>
- <h3 id='tymethod.notify' class='method'><span id='notify.v' class='invisible'><code>fn <a href='#tymethod.notify' class='fnname'>notify</a>(&self, id: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></span></h3><div class='docblock'><p>Indicates that an associated future and/or task are ready to make
- progress.</p>
- <p>Typically this means that the receiver of the notification should
- arrange for the future to get poll'd in a prompt fashion.</p>
- <p>This method takes an <code>id</code> as an argument which was transitively passed
- in from the original call to <code>Spawn::*_notify</code>. This id can be used to
- disambiguate which precise future became ready for polling.</p>
- <h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
- <p>Since <code>unpark</code> may be invoked from arbitrary contexts, it should
- endeavor not to panic and to do as little work as possible. However, it
- is not guaranteed not to panic, and callers should be wary. If a panic
- occurs, that panic may or may not be propagated to the end-user of the
- future that you'd otherwise wake up.</p>
- </div></div>
- <h2 id='provided-methods' class='small-section-header'>
- Provided Methods<a href='#provided-methods' class='anchor'></a>
- </h2>
- <div class='methods'>
- <h3 id='method.clone_id' class='method'><span id='clone_id.v' class='invisible'><code>fn <a href='#method.clone_id' class='fnname'>clone_id</a>(&self, id: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></span></h3><div class='docblock'><p>This function is called whenever a new copy of <code>id</code> is needed.</p>
- <p>This is called in one of two situations:</p>
- <ul>
- <li>A <code>Task</code> is being created through <code>task::current</code> while a future is
- being polled. In that case the instance of <code>Notify</code> passed in to one
- of the <code>poll_*</code> functions is called with the <code>id</code> passed into the same
- <code>poll_*</code> function.</li>
- <li>A <code>Task</code> is itself being cloned. Each <code>Task</code> contains its own id and a
- handle to the <code>Notify</code> behind it, and the task's <code>Notify</code> is used to
- clone the internal <code>id</code> to assign to the new task.</li>
- </ul>
- <p>The <code>id</code> returned here will be stored in the <code>Task</code>-to-be and used later
- to pass to <code>notify</code> when the <code>Task::notify</code> function is called on that
- <code>Task</code>.</p>
- <p>Note that typically this is just the identity function, passing through
- the identifier. For more unsafe situations, however, if <code>id</code> is itself a
- pointer of some kind this can be used as a hook to "clone" the pointer,
- depending on what that means for the specified pointer.</p>
- </div><h3 id='method.drop_id' class='method'><span id='drop_id.v' class='invisible'><code>fn <a href='#method.drop_id' class='fnname'>drop_id</a>(&self, id: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></span></h3><div class='docblock'><p>All instances of <code>Task</code> store an <code>id</code> that they're going to internally
- notify with, and this function is called when the <code>Task</code> is dropped.</p>
- <p>This function provides a hook for schemes which encode pointers in this
- <code>id</code> argument to deallocate resources associated with the pointer. It's
- guaranteed that after this function is called the <code>Task</code> containing this
- <code>id</code> will no longer use the <code>id</code>.</p>
- </div></div>
- <h2 id='implementors' class='small-section-header'>
- Implementors<a href='#implementors' class='anchor'></a>
- </h2>
- <ul class='item-list' id='implementors-list'>
- </ul><script type="text/javascript">window.inlined_types=new Set([]);</script><script type="text/javascript" async
- src="../../implementors/futures/executor/trait.Notify.js">
- </script></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "futures";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|