continuable/classcti_1_1promise__base.html
Denis Blank 94dc953ba9 Publish
2023-03-21 21:05:30 +01:00

371 lines
24 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>cti::promise_base class | Continuable</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
<link rel="stylesheet" href="m-dark+doxygen.compiled.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
<link rel="stylesheet" href="base.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
<link rel="stylesheet" href="terminal.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
<link rel="stylesheet" href="atom-one-dark.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#23373B" />
</head>
<body>
<header><nav id="navigation">
<div class="m-container">
<div class="m-row">
<a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">Continuable <span class="m-thin">4.1.0</span></a>
<div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
<a href="#search" class="m-dox-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<path d="m6 0c-3.3144 0-6 2.6856-6 6 0 3.3144 2.6856 6 6 6 1.4858 0 2.8463-0.54083 3.8945-1.4355-0.0164 0.33797 0.14734 0.75854 0.5 1.1504l3.2227 3.7891c0.55185 0.6139 1.4517 0.66544 2.002 0.11524 0.55022-0.55022 0.49866-1.4501-0.11524-2.002l-3.7891-3.2246c-0.39184-0.35266-0.81242-0.51469-1.1504-0.5 0.89472-1.0482 1.4355-2.4088 1.4355-3.8945 0-3.3128-2.6856-5.998-6-5.998zm0 1.5625a4.4375 4.4375 0 0 1 4.4375 4.4375 4.4375 4.4375 0 0 1-4.4375 4.4375 4.4375 4.4375 0 0 1-4.4375-4.4375 4.4375 4.4375 0 0 1 4.4375-4.4375z"/>
</svg></a>
<a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
<a id="m-navbar-hide" href="#" title="Hide navigation"></a>
</div>
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
<li>
<a href="tutorial.html">Tutorial</a>
<ol>
<li><a href="tutorial-creating-continuables.html">Creating continuables</a></li>
<li><a href="tutorial-chaining-continuables.html">Chaining continuables</a></li>
<li><a href="tutorial-connecting-continuables.html">Connecting continuables</a></li>
<li><a href="tutorial-transforming-continuables.html">Transforming continuables</a></li>
<li><a href="tutorial-awaiting-continuables.html">Awaiting continuables</a></li>
<li><a href="tutorial-promisify-continuables.html">Promisify functions</a></li>
</ol>
</li>
<li>
<a href="pages.html">Pages</a>
<ol>
<li><a href="installation.html">Installation</a></li>
<li><a href="tutorial.html">Tutorial</a></li>
<li><a href="configuration.html">Configuration</a></li>
<li><a href="changelog.html">Changelog</a></li>
</ol>
</li>
<li>
<a href="modules.html">Modules</a>
<ol>
<li><a href="group___base.html">Base</a></li>
<li><a href="group___connections.html">Connections</a></li>
<li><a href="group___promisify.html">Promisify</a></li>
<li><a href="group___testing.html">Testing</a></li>
<li><a href="group___types.html">Types</a></li>
<li><a href="group___transforms.html">Transforms</a></li>
<li><a href="group___traversal.html">Traversal</a></li>
</ol>
</li>
</ol>
<ol class="m-col-t-6 m-col-m-none" start="4">
<li>
<a href="namespacecti.html">cti</a>
<ol>
<li><a href="namespacecti_1_1transforms.html">cti::transforms</a></li>
<li><a href="classcti_1_1continuable__base.html">cti::continuable_base</a></li>
<li><a href="classcti_1_1promise__base.html" id="m-navbar-current">cti::promise_base</a></li>
</ol>
</li>
<li class="m-show-m"><a href="#search" class="m-dox-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<path d="m6 0c-3.3144 0-6 2.6856-6 6 0 3.3144 2.6856 6 6 6 1.4858 0 2.8463-0.54083 3.8945-1.4355-0.0164 0.33797 0.14734 0.75854 0.5 1.1504l3.2227 3.7891c0.55185 0.6139 1.4517 0.66544 2.002 0.11524 0.55022-0.55022 0.49866-1.4501-0.11524-2.002l-3.7891-3.2246c-0.39184-0.35266-0.81242-0.51469-1.1504-0.5 0.89472-1.0482 1.4355-2.4088 1.4355-3.8945 0-3.3128-2.6856-5.998-6-5.998zm0 1.5625a4.4375 4.4375 0 0 1 4.4375 4.4375 4.4375 4.4375 0 0 1-4.4375 4.4375 4.4375 4.4375 0 0 1-4.4375-4.4375 4.4375 4.4375 0 0 1 4.4375-4.4375z"/>
</svg> Search</a></li>
</ol>
<ol class="m-col-t-6 m-col-m-none">
<li>
<a href="https://github.com/Naios/continuable" aria-label="View source on Github"><i class="fa fa-github"></i> Code</a>
</li>
</ol>
</div>
</div>
</div>
</div>
</nav></header>
<main><article>
<div class="m-container m-container-inflatable">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<h1>
<div class="m-dox-template">template&lt;typename Data, typename Hint&gt;</div>
<span class="m-breadcrumb"><a href="namespacecti.html">cti</a>::<wbr/></span>promise_base <span class="m-thin">class</span>
</h1>
<p>The <a href="classcti_1_1promise__base.html" class="m-dox">promise_<wbr />base</a> makes it possible to resolve an asynchronous continuable through it&#x27;s result or through an error type.</p>
<div class="m-block m-default">
<h3>Contents</h3>
<ul>
<li>
Reference
<ul>
<li><a href="#typeless-methods">Constructors, destructors, conversion operators</a></li>
<li><a href="#pub-methods">Public functions</a></li>
</ul>
</li>
</ul>
</div>
<p>Use the promise type defined in <code>continuable/continuable_types.hpp</code>, in order to use this class.</p><p>If we want to resolve the <a href="classcti_1_1promise__base.html" class="m-dox">promise_<wbr />base</a> trough the call operator, and we want to resolve it through an exception, we must call it with a <a href="structcti_1_1exception__arg__t.html" class="m-dox">exception_<wbr />arg_<wbr />t</a> as first and the exception as second argument. Additionally the promise is resolveable only through its call operator when invoked as an r-value.</p><aside class="m-note m-default"><h4>Since</h4><p>2.0.0</p></aside>
<section id="typeless-methods">
<h2><a href="#typeless-methods">Constructors, destructors, conversion operators</a></h2>
<dl class="m-dox">
<dt>
<span class="m-dox-wrap-bumper"><a href="#a2885e8c4a6a8d2a3fc5833c0b6246a2e" class="m-dox-self" name="a2885e8c4a6a8d2a3fc5833c0b6246a2e">promise_base</a>(</span><span class="m-dox-wrap">) <span class="m-label m-flat m-info">defaulted</span> <span class="m-label m-flat m-info">explicit</span> </span>
</dt>
<dd>Constructor for constructing an empty promise.</dd>
<dt>
<span class="m-dox-wrap-bumper"><a href="#aef8b6fbfcc15572b829770f28324e4f0" class="m-dox-self" name="aef8b6fbfcc15572b829770f28324e4f0">promise_base</a>(</span><span class="m-dox-wrap">Data data) <span class="m-label m-flat m-info">explicit</span> </span>
</dt>
<dd>Constructor accepting the data object.</dd>
<dt>
<div class="m-dox-template">template&lt;typename OData, std::enable_if_t&lt;std::is_convertible&lt;detail::traits::unrefcv_t&lt;OData&gt;, Data&gt;::value&gt;* = nullptr&gt;</div>
<span class="m-dox-wrap-bumper"><a href="#aa3fd45949359892e71aa0b10cf9fa1f5" class="m-dox-self" name="aa3fd45949359892e71aa0b10cf9fa1f5">promise_base</a>(</span><span class="m-dox-wrap">OData&amp;&amp; data)</span>
</dt>
<dd>Constructor accepting any object convertible to the data object.</dd>
<dt>
<span class="m-dox-wrap-bumper"><a href="#a463a4e8bbed77b485bf3e1658bf2aa19" class="m-dox">operator bool</a>(</span><span class="m-dox-wrap">) const <span class="m-label m-flat m-info">explicit</span> <span class="m-label m-flat m-success">noexcept</span></span>
</dt>
<dd>Returns true if the continuation is valid (non empty).</dd>
</dl>
</section>
<section id="pub-methods">
<h2><a href="#pub-methods">Public functions</a></h2>
<dl class="m-dox">
<dt>
<div class="m-dox-template">template&lt;typename OData, std::enable_if_t&lt;std::is_convertible&lt;detail::traits::unrefcv_t&lt;OData&gt;, Data&gt;::value&gt;* = nullptr&gt;</div>
<span class="m-dox-wrap-bumper">auto <a href="#ab212900670383825bcfb548f9c43eb9b" class="m-dox-self" name="ab212900670383825bcfb548f9c43eb9b">operator=</a>(</span><span class="m-dox-wrap">OData&amp;&amp; data) -&gt; <a href="classcti_1_1promise__base.html" class="m-dox">promise_<wbr />base</a>&amp;</span>
</dt>
<dd>Assignment operator accepting any object convertible to the data object.</dd>
<dt>
<span class="m-dox-wrap-bumper">void <a href="#a87d5dfa33e141e08abef9f2a83f87c78" class="m-dox">operator()</a>(</span><span class="m-dox-wrap">Args... args) &amp;&amp;noexcept</span>
</dt>
<dd>Resolves the continuation with the given values.</dd>
<dt>
<span class="m-dox-wrap-bumper">void <a href="#adca9714bd11fcbaa4e9c145758feed8b" class="m-dox">operator()</a>(</span><span class="m-dox-wrap"><a href="structcti_1_1exception__arg__t.html" class="m-dox">exception_<wbr />arg_<wbr />t</a> tag,
<a href="group___primitives.html#ga9fa0d3597f70a7b9e763639f0b30dee1" class="m-dox">exception_<wbr />t</a> exception) &amp;&amp;noexcept</span>
</dt>
<dd>Resolves the continuation with the given exception.</dd>
<dt>
<span class="m-dox-wrap-bumper">void <a href="#a223d666944a70441b3837b461b1094c7" class="m-dox">set_value</a>(</span><span class="m-dox-wrap">Args... args) <span class="m-label m-flat m-success">noexcept</span></span>
</dt>
<dd>Resolves the continuation with the given values.</dd>
<dt>
<span class="m-dox-wrap-bumper">void <a href="#a449356e97645d44cf4194932cc2006d7" class="m-dox">set_exception</a>(</span><span class="m-dox-wrap"><a href="group___primitives.html#ga9fa0d3597f70a7b9e763639f0b30dee1" class="m-dox">exception_<wbr />t</a> exception) <span class="m-label m-flat m-success">noexcept</span></span>
</dt>
<dd>Resolves the continuation with the given exception.</dd>
<dt>
<span class="m-dox-wrap-bumper">void <a href="#aed6c513624ac46d265a4d0695aef8820" class="m-dox">set_canceled</a>(</span><span class="m-dox-wrap">) <span class="m-label m-flat m-success">noexcept</span></span>
</dt>
<dd>Resolves the continuation with the cancellation token which is represented by a default constructed exception_t.</dd>
</dl>
</section>
<section>
<h2>Function documentation</h2>
<section class="m-dox-details" id="a463a4e8bbed77b485bf3e1658bf2aa19"><div>
<h3>
<div class="m-dox-template">
template&lt;typename Data, typename Hint&gt;
</div>
<span class="m-dox-wrap-bumper"> cti::<wbr />promise_base&lt;Data, Hint&gt;::<wbr /></span><span class="m-dox-wrap"><span class="m-dox-wrap-bumper"><a href="#a463a4e8bbed77b485bf3e1658bf2aa19" class="m-dox-self">operator bool</a>(</span><span class="m-dox-wrap">) const <span class="m-label m-info">explicit</span> <span class="m-label m-success">noexcept</span></span></span>
</h3>
<p>Returns true if the continuation is valid (non empty).</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Exceptions</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">This</td>
<td>method never throws an exception.</td>
</tr>
</tbody>
</table>
<aside class="m-note m-default"><h4>Since</h4><p>4.0.0</p></aside>
</div></section>
<section class="m-dox-details" id="a87d5dfa33e141e08abef9f2a83f87c78"><div>
<h3>
<div class="m-dox-template">
template&lt;typename Data, typename Hint&gt;
</div>
<span class="m-dox-wrap-bumper">void cti::<wbr />promise_base&lt;Data, Hint&gt;::<wbr /></span><span class="m-dox-wrap"><span class="m-dox-wrap-bumper"><a href="#a87d5dfa33e141e08abef9f2a83f87c78" class="m-dox-self">operator()</a>(</span><span class="m-dox-wrap">Args... args) &amp;&amp;noexcept</span></span>
</h3>
<p>Resolves the continuation with the given values.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Exceptions</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">This</td>
<td>method never throws an exception.</td>
</tr>
</tbody>
</table>
<aside class="m-note m-warning"><h4>Attention</h4><p>This method may only be called once, when the promise is valid operator bool() returns true. Calling this method will invalidate the promise such that subsequent calls to operator bool() will return false. This behaviour is only consistent in <a href="classcti_1_1promise__base.html" class="m-dox">promise_<wbr />base</a> and non type erased promises may behave differently. Invoking an invalid <a href="classcti_1_1promise__base.html" class="m-dox">promise_<wbr />base</a> is undefined!</p></aside><aside class="m-note m-default"><h4>Since</h4><p>2.0.0</p></aside>
</div></section>
<section class="m-dox-details" id="adca9714bd11fcbaa4e9c145758feed8b"><div>
<h3>
<div class="m-dox-template">
template&lt;typename Data, typename Hint&gt;
</div>
<span class="m-dox-wrap-bumper">void cti::<wbr />promise_base&lt;Data, Hint&gt;::<wbr /></span><span class="m-dox-wrap"><span class="m-dox-wrap-bumper"><a href="#adca9714bd11fcbaa4e9c145758feed8b" class="m-dox-self">operator()</a>(</span><span class="m-dox-wrap"><a href="structcti_1_1exception__arg__t.html" class="m-dox">exception_<wbr />arg_<wbr />t</a> tag,
<a href="group___primitives.html#ga9fa0d3597f70a7b9e763639f0b30dee1" class="m-dox">exception_<wbr />t</a> exception) &amp;&amp;noexcept</span></span>
</h3>
<p>Resolves the continuation with the given exception.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Exceptions</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">This</td>
<td>method never throws an exception.</td>
</tr>
</tbody>
</table>
<aside class="m-note m-warning"><h4>Attention</h4><p>This method may only be called once, when the promise is valid operator bool() returns true. Calling this method will invalidate the promise such that subsequent calls to operator bool() will return false. This behaviour is only consistent in <a href="classcti_1_1promise__base.html" class="m-dox">promise_<wbr />base</a> and non type erased promises may behave differently. Invoking an invalid <a href="classcti_1_1promise__base.html" class="m-dox">promise_<wbr />base</a> is undefined!</p></aside><aside class="m-note m-default"><h4>Since</h4><p>2.0.0</p></aside>
</div></section>
<section class="m-dox-details" id="a223d666944a70441b3837b461b1094c7"><div>
<h3>
<div class="m-dox-template">
template&lt;typename Data, typename Hint&gt;
</div>
<span class="m-dox-wrap-bumper">void cti::<wbr />promise_base&lt;Data, Hint&gt;::<wbr /></span><span class="m-dox-wrap"><span class="m-dox-wrap-bumper"><a href="#a223d666944a70441b3837b461b1094c7" class="m-dox-self">set_value</a>(</span><span class="m-dox-wrap">Args... args) <span class="m-label m-success">noexcept</span></span></span>
</h3>
<p>Resolves the continuation with the given values.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Exceptions</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">This</td>
<td>method never throws an exception.</td>
</tr>
</tbody>
</table>
<aside class="m-note m-warning"><h4>Attention</h4><p>This method may only be called once, when the promise is valid operator bool() returns true. Calling this method will invalidate the promise such that subsequent calls to operator bool() will return false. This behaviour is only consistent in <a href="classcti_1_1promise__base.html" class="m-dox">promise_<wbr />base</a> and non type erased promises may behave differently. Invoking an invalid <a href="classcti_1_1promise__base.html" class="m-dox">promise_<wbr />base</a> is undefined!</p></aside><aside class="m-note m-default"><h4>Since</h4><p>2.0.0</p></aside>
</div></section>
<section class="m-dox-details" id="a449356e97645d44cf4194932cc2006d7"><div>
<h3>
<div class="m-dox-template">
template&lt;typename Data, typename Hint&gt;
</div>
<span class="m-dox-wrap-bumper">void cti::<wbr />promise_base&lt;Data, Hint&gt;::<wbr /></span><span class="m-dox-wrap"><span class="m-dox-wrap-bumper"><a href="#a449356e97645d44cf4194932cc2006d7" class="m-dox-self">set_exception</a>(</span><span class="m-dox-wrap"><a href="group___primitives.html#ga9fa0d3597f70a7b9e763639f0b30dee1" class="m-dox">exception_<wbr />t</a> exception) <span class="m-label m-success">noexcept</span></span></span>
</h3>
<p>Resolves the continuation with the given exception.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Exceptions</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">This</td>
<td>method never throws an exception.</td>
</tr>
</tbody>
</table>
<aside class="m-note m-warning"><h4>Attention</h4><p>This method may only be called once, when the promise is valid operator bool() returns true. Calling this method will invalidate the promise such that subsequent calls to operator bool() will return false. This behaviour is only consistent in <a href="classcti_1_1promise__base.html" class="m-dox">promise_<wbr />base</a> and non type erased promises may behave differently. Invoking an invalid <a href="classcti_1_1promise__base.html" class="m-dox">promise_<wbr />base</a> is undefined!</p></aside><aside class="m-note m-default"><h4>Since</h4><p>2.0.0</p></aside>
</div></section>
<section class="m-dox-details" id="aed6c513624ac46d265a4d0695aef8820"><div>
<h3>
<div class="m-dox-template">
template&lt;typename Data, typename Hint&gt;
</div>
<span class="m-dox-wrap-bumper">void cti::<wbr />promise_base&lt;Data, Hint&gt;::<wbr /></span><span class="m-dox-wrap"><span class="m-dox-wrap-bumper"><a href="#aed6c513624ac46d265a4d0695aef8820" class="m-dox-self">set_canceled</a>(</span><span class="m-dox-wrap">) <span class="m-label m-success">noexcept</span></span></span>
</h3>
<p>Resolves the continuation with the cancellation token which is represented by a default constructed exception_t.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Exceptions</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">This</td>
<td>method never throws an exception.</td>
</tr>
</tbody>
</table>
<aside class="m-note m-warning"><h4>Attention</h4><p>This method may only be called once, when the promise is valid operator bool() returns true. Calling this method will invalidate the promise such that subsequent calls to operator bool() will return false. This behaviour is only consistent in <a href="classcti_1_1promise__base.html" class="m-dox">promise_<wbr />base</a> and non type erased promises may behave differently. Invoking an invalid <a href="classcti_1_1promise__base.html" class="m-dox">promise_<wbr />base</a> is undefined!</p></aside><aside class="m-note m-default"><h4>Since</h4><p>4.0.0</p></aside>
</div></section>
</section>
</div>
</div>
</div>
</article></main>
<div class="m-dox-search" id="search">
<a href="#!" onclick="return hideSearch()"></a>
<div class="m-container">
<div class="m-row">
<div class="m-col-m-8 m-push-m-2">
<div class="m-dox-search-header m-text m-small">
<div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
<div id="search-symbolcount">&hellip;</div>
</div>
<div class="m-dox-search-content">
<form>
<input type="search" name="q" id="search-input" placeholder="Loading &hellip;" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
<p class="m-noindent">Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
<code>:</code> or <code>/</code> suffix lists all members of given symbol or
directory.</p>
<p class="m-noindent">Use <span class="m-label m-dim">&darr;</span>
/ <span class="m-label m-dim">&uarr;</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
copy a link to the result using <span class="m-label m-dim"></span>
<span class="m-label m-dim">L</span> while <span class="m-label m-dim"></span>
<span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
</div>
</div>
</div>
</div>
</div>
<script src="search.js"></script>
<script src="searchdata.js" async="async"></script>
<footer><nav>
<div class="m-container">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<b><a
href="https://github.com/Naios/continuable">continuable</a></b>
-
C++14
allocation
aware
futures</br>Copyright
2015&ndash;2020
<a
href="https://github.com/Naios">Denis
Blank</a>.
Contact
the
author
via
<a
href="mailto:denis.blank@outlook.com">e-mail</a>.</br>Powered
by
<a
href="http://doxygen.org/">Doxygen</a>
and
<a
href="http://mcss.mosra.cz/">m.css</a>
</div>
</div>
</div>
</nav></footer>
</body>
</html>