153 lines
No EOL
8.1 KiB
HTML
153 lines
No EOL
8.1 KiB
HTML
<!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 `Scope` struct in crate `scoped_pool`.">
|
||
<meta name="keywords" content="rust, rustlang, rust-lang, Scope">
|
||
|
||
<title>scoped_pool::Scope - Rust</title>
|
||
|
||
<link rel="stylesheet" type="text/css" href="../rustdoc.css">
|
||
<link rel="stylesheet" type="text/css" href="../main.css">
|
||
|
||
|
||
|
||
|
||
</head>
|
||
<body class="rustdoc">
|
||
<!--[if lte IE 8]>
|
||
<div class="warning">
|
||
This old browser is unsupported and will most likely display funky
|
||
things.
|
||
</div>
|
||
<![endif]-->
|
||
|
||
|
||
|
||
<nav class="sidebar">
|
||
|
||
<p class='location'><a href='index.html'>scoped_pool</a></p><script>window.sidebarCurrent = {name: 'Scope', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
|
||
</nav>
|
||
|
||
<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">
|
||
</div>
|
||
</form>
|
||
</nav>
|
||
|
||
<section id='main' class="content struct">
|
||
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>scoped_pool</a>::<wbr><a class='struct' href=''>Scope</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 id='src-51' class='srclink' href='../src/scoped_pool/lib.rs.html#180-184' title='goto source code'>[src]</a></span></h1>
|
||
<pre class='rust struct'>pub struct Scope<'scope> {
|
||
// some fields omitted
|
||
}</pre><div class='docblock'><p>An execution scope, represents a set of jobs running on a Pool.</p>
|
||
|
||
<h2 id='understanding-scope-lifetimes' class='section-header'><a href='#understanding-scope-lifetimes'>Understanding Scope lifetimes</a></h2>
|
||
<p>Besides <code>Scope<'static></code>, all <code>Scope</code> objects are accessed behind a
|
||
reference of the form <code>&'scheduler Scope<'scope></code>.</p>
|
||
|
||
<p><code>'scheduler</code> is the lifetime associated with the <em>body</em> of the
|
||
"scheduler" function (functions passed to <code>zoom</code>/<code>scoped</code>).</p>
|
||
|
||
<p><code>'scope</code> is the lifetime which data captured in <code>execute</code> or <code>recurse</code>
|
||
closures must outlive - in other words, <code>'scope</code> is the maximum lifetime
|
||
of all jobs scheduler on a <code>Scope</code>.</p>
|
||
|
||
<p>Note that since <code>'scope: 'scheduler</code> (<code>'scope</code> outlives <code>'scheduler</code>)
|
||
<code>&'scheduler Scope<'scope></code> can't be captured in an <code>execute</code> closure;
|
||
this is the reason for the existence of the <code>recurse</code> API, which will
|
||
inject the same scope with a new <code>'scheduler</code> lifetime (this time set
|
||
to the body of the function passed to <code>recurse</code>).</p>
|
||
</div><h2 id='methods'>Methods</h2><h3 class='impl'><code>impl<'scope> <a class='struct' href='../scoped_pool/struct.Scope.html' title='scoped_pool::Scope'>Scope</a><'scope></code></h3><div class='impl-items'><h4 id='method.forever' class='method'><code>fn <a href='#method.forever' class='fnname'>forever</a>(pool: <a class='struct' href='../scoped_pool/struct.Pool.html' title='scoped_pool::Pool'>Pool</a>) -> <a class='struct' href='../scoped_pool/struct.Scope.html' title='scoped_pool::Scope'>Scope</a><'static></code></h4>
|
||
<div class='docblock'><p>Create a Scope which lasts forever.</p>
|
||
</div><h4 id='method.execute' class='method'><code>fn <a href='#method.execute' class='fnname'>execute</a><F>(&self, job: F) <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnOnce.html' title='core::ops::FnOnce'>FnOnce</a>() + <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Send.html' title='core::marker::Send'>Send</a> + 'scope</span></code></h4>
|
||
<div class='docblock'><p>Add a job to this scope.</p>
|
||
|
||
<p>Subsequent calls to <code>join</code> will wait for this job to complete.</p>
|
||
</div><h4 id='method.recurse' class='method'><code>fn <a href='#method.recurse' class='fnname'>recurse</a><F>(&self, job: F) <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnOnce.html' title='core::ops::FnOnce'>FnOnce</a>(&Self) + <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Send.html' title='core::marker::Send'>Send</a> + 'scope</span></code></h4>
|
||
<div class='docblock'><p>Add a job to this scope which itself will get access to the scope.</p>
|
||
|
||
<p>Like with <code>execute</code>, subsequent calls to <code>join</code> will wait for this
|
||
job (and all jobs scheduled on the scope it receives) to complete.</p>
|
||
</div><h4 id='method.zoom' class='method'><code>fn <a href='#method.zoom' class='fnname'>zoom</a><'smaller, F, R>(&self, scheduler: F) -> R <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnOnce.html' title='core::ops::FnOnce'>FnOnce</a>(&<a class='struct' href='../scoped_pool/struct.Scope.html' title='scoped_pool::Scope'>Scope</a><'smaller>) -> R, 'scope: 'smaller</span></code></h4>
|
||
<div class='docblock'><p>Create a new subscope, bound to a lifetime smaller than our existing Scope.</p>
|
||
|
||
<p>The subscope has a different job set, and is joined before zoom returns.</p>
|
||
</div><h4 id='method.join' class='method'><code>fn <a href='#method.join' class='fnname'>join</a>(&self)</code></h4>
|
||
<div class='docblock'><p>Awaits all jobs submitted on this Scope to be completed.</p>
|
||
|
||
<p>Only guaranteed to join jobs which where <code>execute</code>d logically
|
||
prior to <code>join</code>. Jobs <code>execute</code>d concurrently with <code>join</code> may
|
||
or may not be completed before <code>join</code> returns.</p>
|
||
</div></div></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>?</dt>
|
||
<dd>Show this help dialog</dd>
|
||
<dt>S</dt>
|
||
<dd>Focus the search field</dd>
|
||
<dt>⇤</dt>
|
||
<dd>Move up in search results</dd>
|
||
<dt>⇥</dt>
|
||
<dd>Move down in search results</dd>
|
||
<dt>⏎</dt>
|
||
<dd>Go to active search result</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>
|
||
</div>
|
||
</div>
|
||
</aside>
|
||
|
||
|
||
|
||
<script>
|
||
window.rootPath = "../";
|
||
window.currentCrate = "scoped_pool";
|
||
window.playgroundUrl = "";
|
||
</script>
|
||
<script src="../jquery.js"></script>
|
||
<script src="../main.js"></script>
|
||
|
||
<script defer src="../search-index.js"></script>
|
||
</body>
|
||
</html> |