Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > ba6e5e1a033bd8535c43a771ce407926 > files > 78

lib64cxx-gtk-utils2.2-devel-2.2.3-2.mga4.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.4"/>
<title>c++-gtk-utils: Cgu::AsyncResult&lt; T &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">c++-gtk-utils
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.4 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceCgu.html">Cgu</a></li><li class="navelem"><a class="el" href="classCgu_1_1AsyncResult.html">AsyncResult</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classCgu_1_1AsyncResult-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Cgu::AsyncResult&lt; T &gt; Class Template Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>A thread-safe asynchronous result class.  
 <a href="classCgu_1_1AsyncResult.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="async__result_8h_source.html">c++-gtk-utils/async_result.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a5084b8009e36650c70a1177de9a2f870"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1AsyncResult.html#a5084b8009e36650c70a1177de9a2f870">AsyncResult</a> ()</td></tr>
<tr class="separator:a5084b8009e36650c70a1177de9a2f870"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a661e63288175e969c3db641eb3f6f4b5"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1AsyncResult.html#a661e63288175e969c3db641eb3f6f4b5">~AsyncResult</a> ()</td></tr>
<tr class="separator:a661e63288175e969c3db641eb3f6f4b5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a989cd3a9bd22eba0316ef45d5e996d9b"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1AsyncResult.html#a989cd3a9bd22eba0316ef45d5e996d9b">AsyncResult</a> (const <a class="el" href="classCgu_1_1AsyncResult.html">AsyncResult</a> &amp;)=delete</td></tr>
<tr class="separator:a989cd3a9bd22eba0316ef45d5e996d9b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acbcd3f48526999696101b9d012917067"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCgu_1_1AsyncResult.html">AsyncResult</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1AsyncResult.html#acbcd3f48526999696101b9d012917067">operator=</a> (const <a class="el" href="classCgu_1_1AsyncResult.html">AsyncResult</a> &amp;)=delete</td></tr>
<tr class="separator:acbcd3f48526999696101b9d012917067"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3cf99fc76547e0155a2d5d1608c22de7"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set</a> (const T &amp;val)</td></tr>
<tr class="separator:a3cf99fc76547e0155a2d5d1608c22de7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad47b2edf239d0153a84f590798f8ae62"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1AsyncResult.html#ad47b2edf239d0153a84f590798f8ae62">set</a> (T &amp;&amp;val)</td></tr>
<tr class="separator:ad47b2edf239d0153a84f590798f8ae62"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8cf43f604c42a48d1a6fa61640c06637"><td class="memItemLeft" align="right" valign="top">T&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1AsyncResult.html#a8cf43f604c42a48d1a6fa61640c06637">get</a> () const </td></tr>
<tr class="separator:a8cf43f604c42a48d1a6fa61640c06637"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acc4835c1722a3d5ce0da50ddd91103d1"><td class="memItemLeft" align="right" valign="top">T&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1AsyncResult.html#acc4835c1722a3d5ce0da50ddd91103d1">move_get</a> ()</td></tr>
<tr class="separator:acc4835c1722a3d5ce0da50ddd91103d1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aabb4ca29e0367f8e279c8b20be3221e0"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1AsyncResult.html#aabb4ca29e0367f8e279c8b20be3221e0">set_error</a> (int err=-1)</td></tr>
<tr class="separator:aabb4ca29e0367f8e279c8b20be3221e0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af2c45b2b9b16319c10d35de7a4061727"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1AsyncResult.html#af2c45b2b9b16319c10d35de7a4061727">get_error</a> () const </td></tr>
<tr class="separator:af2c45b2b9b16319c10d35de7a4061727"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af5f425d599a8a4343d1642b65f5a346e"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1AsyncResult.html#af5f425d599a8a4343d1642b65f5a346e">is_done</a> () const </td></tr>
<tr class="separator:af5f425d599a8a4343d1642b65f5a346e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;class T&gt;<br/>
class Cgu::AsyncResult&lt; T &gt;</h3>

<p>A thread-safe asynchronous result class. </p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classCgu_1_1AsyncQueueDispatch.html" title="A thread-safe asynchronous queue with a blocking pop() method. ">AsyncQueueDispatch</a> <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Thread::Future</a></dd></dl>
<p><a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a> operates on the principle of there being one worker thread per task. In some cases however, it may be better to have a worker thread, or a limited pool of worker threads, executing a larger number of tasks. This can be implemented by having a worker thread or threads waiting on a <a class="el" href="classCgu_1_1AsyncQueueDispatch.html" title="A thread-safe asynchronous queue with a blocking pop() method. ">Cgu::AsyncQueueDispatch</a> object, onto which other threads push tasks represented by std::unique_ptr&lt;const Cgu::Callback::Callback&gt; or <a class="el" href="namespaceCgu_1_1Callback.html#ace69d350a8b9ba8ecbc309e0a8ecdc97">Cgu::Callback::SafeFunctor</a> objects.</p>
<p>Where this model is adopted, when a task completes it may report its results by dispatching a further callback to a glib main loop using <a class="el" href="namespaceCgu_1_1Callback.html#ab8a459b25b1dba52fd43015c694bab1d">Cgu::Callback::post()</a>. However, there will also be cases where, rather than passing a result as an event to a main loop, a thread is to to wait for the task to complete. This class is intended to facilitate that. It operates in a way which is similar to the std::promise class in C++11. The thread which wishes to extract a result can call the <a class="el" href="classCgu_1_1AsyncResult.html#a8cf43f604c42a48d1a6fa61640c06637">get()</a> method, which will block until the worker thread has called the <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a> method or posted an error.</p>
<p>For safety reasons, the <a class="el" href="classCgu_1_1AsyncResult.html#a8cf43f604c42a48d1a6fa61640c06637">get()</a> method returns by value and so will cause that value to be copied once. From version 2.0.11 a <a class="el" href="classCgu_1_1AsyncResult.html#acc4835c1722a3d5ce0da50ddd91103d1">move_get()</a> method is provided which will make a move operation instead of a copy if the value type implements a move constructor, but see the documentation on <a class="el" href="classCgu_1_1AsyncResult.html#acc4835c1722a3d5ce0da50ddd91103d1">move_get()</a> for the caveats with respect to its use: in particular, if <a class="el" href="classCgu_1_1AsyncResult.html#acc4835c1722a3d5ce0da50ddd91103d1">move_get()</a> is to be called by a thread, then <a class="el" href="classCgu_1_1AsyncResult.html#a8cf43f604c42a48d1a6fa61640c06637">get()</a> may not be called by another thread.</p>
<p>Here is a compilable example of a calculator class which runs a dedicated thread on which it carries out all its calculations:</p>
<div class="fragment"><div class="line"><span class="preprocessor"> #include &lt;vector&gt;</span></div>
<div class="line"><span class="preprocessor"> #include &lt;numeric&gt;</span></div>
<div class="line"><span class="preprocessor"> #include &lt;memory&gt;</span></div>
<div class="line"><span class="preprocessor"> #include &lt;ostream&gt;</span></div>
<div class="line"><span class="preprocessor"> #include &lt;iostream&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor"> #include &lt;<a class="code" href="async__result_8h.html" title="This file provides a thread-safe asynchronous result class. ">c++-gtk-utils/async_result.h</a>&gt;</span></div>
<div class="line"><span class="preprocessor"> #include &lt;<a class="code" href="async__queue_8h.html" title="This file provides thread-safe asynchronous queue classes. ">c++-gtk-utils/async_queue.h</a>&gt;</span></div>
<div class="line"><span class="preprocessor"> #include &lt;<a class="code" href="shared__ptr_8h.html">c++-gtk-utils/shared_ptr.h</a>&gt;</span></div>
<div class="line"><span class="preprocessor"> #include &lt;<a class="code" href="thread_8h.html">c++-gtk-utils/thread.h</a>&gt;</span></div>
<div class="line"><span class="preprocessor"> #include &lt;<a class="code" href="callback_8h.html" title="This file provides classes for type erasure. ">c++-gtk-utils/callback.h</a>&gt;</span></div>
<div class="line"></div>
<div class="line"> <span class="keyword">using namespace </span>Cgu;</div>
<div class="line"></div>
<div class="line"> <span class="keyword">class </span>Calcs {</div>
<div class="line">   <a class="code" href="classCgu_1_1AsyncQueueDispatch.html" title="A thread-safe asynchronous queue with a blocking pop() method. ">AsyncQueueDispatch&lt;std::unique_ptr&lt;const Callback::Callback&gt;</a>&gt; jobs;</div>
<div class="line">   <a class="code" href="classCgu_1_1Thread_1_1JoinableHandle.html" title="A class wrapping a Thread::Thread object representing a joinable thread. ">Thread::JoinableHandle</a> t;</div>
<div class="line"></div>
<div class="line">   <span class="keywordtype">void</span> do_jobs() {</div>
<div class="line">     <span class="keywordflow">for</span> (;;) {</div>
<div class="line">       std::unique_ptr&lt;const Callback::Callback&gt; job;</div>
<div class="line">       jobs.move_pop_dispatch(job);</div>
<div class="line">       job-&gt;<a class="code" href="classCgu_1_1Callback_1_1CallbackArg.html#af60695ee22ec4d28dca43132f285c01d">dispatch</a>();</div>
<div class="line">     }</div>
<div class="line">   }</div>
<div class="line"> <span class="keyword">public</span>:</div>
<div class="line"></div>
<div class="line">   <a class="code" href="classCgu_1_1SharedLockPtr.html" title="This is a smart pointer for managing the lifetime of objects allocated on freestore, with a thread safe reference count. ">SharedLockPtr&lt;AsyncResult&lt;double&gt;</a>&gt; mean(<span class="keyword">const</span> std::vector&lt;double&gt;&amp; nums) {</div>
<div class="line">     <a class="code" href="classCgu_1_1SharedLockPtr.html" title="This is a smart pointer for managing the lifetime of objects allocated on freestore, with a thread safe reference count. ">SharedLockPtr&lt;AsyncResult&lt;double&gt;</a>&gt; res(<span class="keyword">new</span> <a class="code" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">AsyncResult&lt;double&gt;</a>);</div>
<div class="line">     jobs.emplace(Callback::lambda&lt;&gt;([=]() {</div>
<div class="line">           <span class="keywordflow">if</span> (nums.empty()) res-&gt;set(0.0);</div>
<div class="line">           <span class="keywordflow">else</span> res-&gt;set(std::accumulate(nums.begin(), nums.end(), 0.0)/nums.size());</div>
<div class="line">         }));</div>
<div class="line">     <span class="keywordflow">return</span> res;</div>
<div class="line">   }</div>
<div class="line"></div>
<div class="line"><span class="comment">// ... other calculation methods here</span></div>
<div class="line"></div>
<div class="line">   Calcs() {</div>
<div class="line">     t = <a class="code" href="classCgu_1_1Thread_1_1JoinableHandle.html" title="A class wrapping a Thread::Thread object representing a joinable thread. ">Thread::JoinableHandle</a>(<a class="code" href="classCgu_1_1Thread_1_1Thread.html#a0c8a852f0739170f6a5ed8657031774c">Thread::Thread::start</a>(<a class="code" href="namespaceCgu_1_1Callback.html#a3e32d4f4961c618aa7e03bda00f398b8">Callback::make</a>(*<span class="keyword">this</span>, &amp;Calcs::do_jobs), <span class="keyword">true</span>), </div>
<div class="line">                                <a class="code" href="classCgu_1_1Thread_1_1JoinableHandle.html#a5515ab9f66ef4388774700c50c2f8910af08a642ae9f85c7c9e1c6e58edbf3ace">Thread::JoinableHandle::join_on_exit</a>);</div>
<div class="line">     <span class="keywordflow">if</span> (!t.is_managing()) <span class="keywordflow">throw</span> <span class="stringliteral">&quot;Thread start error&quot;</span>;</div>
<div class="line">   }</div>
<div class="line">   ~Calcs() {</div>
<div class="line">     jobs.emplace(Callback::lambda&lt;&gt;([]() {<span class="keywordflow">throw</span> <a class="code" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Thread::Exit</a>();}));</div>
<div class="line">     t.join();</div>
<div class="line">   }</div>
<div class="line"> };</div>
<div class="line"></div>
<div class="line"> <span class="keywordtype">int</span> main () {</div>
<div class="line"></div>
<div class="line">   Calcs calcs;</div>
<div class="line">   <span class="keyword">auto</span> res1 = calcs.mean({1, 2, 8, 0});</div>
<div class="line">   <span class="keyword">auto</span> res2 = calcs.mean({101, 53.7, 87, 1.2});</div>
<div class="line"></div>
<div class="line">   <span class="comment">// ... do something else</span></div>
<div class="line"></div>
<div class="line">   std::cout &lt;&lt; res1-&gt;get() &lt;&lt; std::endl;</div>
<div class="line">   std::cout &lt;&lt; res2-&gt;get() &lt;&lt; std::endl;</div>
<div class="line"></div>
<div class="line"> }</div>
</div><!-- fragment --><p><a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">AsyncResult</a> objects cannot be copied by value, and as they need to be visible both to the <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a>ing and <a class="el" href="classCgu_1_1AsyncResult.html#a8cf43f604c42a48d1a6fa61640c06637">get()</a>ing threads, it will often be easiest to construct them on free store and copy them by smart pointer, as in the example above. However, if the library is compiled with the --with-glib-memory-slices-compat or --with-glib-memory-slices-no-compat configuration options, any <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">AsyncResult</a> object constructed on free store will be constructed in glib memory slices, which are an efficient small object allocator. </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a5084b8009e36650c70a1177de9a2f870"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; T &gt;::<a class="el" href="classCgu_1_1AsyncResult.html">AsyncResult</a> </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1MutexError.html">Thread::MutexError</a></td><td>The constructor might throw this exception if initialisation of the contained mutex fails. (It is often not worth checking for this, as it means either memory is exhausted or pthread has run out of other resources to create new mutexes.) The constructor will also throw if the default constructor of the result type represented by this object throws. </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1CondError.html">Thread::CondError</a></td><td>The constructor might throw this exception if initialisation of the contained condition variable fails. (It is often not worth checking for this, as it means either memory is exhausted or pthread has run out of other resources to create new condition variables.) The constructor will also throw if the default constructor of the result type represented by this object throws.</td></tr>
  </table>
  </dd>
</dl>
<p>Since 2.0.8 </p>

</div>
</div>
<a class="anchor" id="a661e63288175e969c3db641eb3f6f4b5"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; T &gt;::~<a class="el" href="classCgu_1_1AsyncResult.html">AsyncResult</a> </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a989cd3a9bd22eba0316ef45d5e996d9b"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; T &gt;::<a class="el" href="classCgu_1_1AsyncResult.html">AsyncResult</a> </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classCgu_1_1AsyncResult.html">AsyncResult</a>&lt; T &gt; &amp;&#160;</td>
          <td class="paramname">)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">delete</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This class cannot be copied. The copy constructor is deleted.</p>
<p>Since 2.0.8 </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a8cf43f604c42a48d1a6fa61640c06637"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">T <a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; T &gt;::get </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This method gets the stored value represented by the <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">AsyncResult</a> object. It is thread safe. It is a cancellation point if it blocks, and is cancellation safe if the stack unwinds on cancellation. Any number of threads may call this method and block on it. It will not throw unless the copy constructor of the return type throws. It is strongly exception safe. </p>
<dl class="section return"><dt>Returns</dt><dd>the value represented by this object as set by a call to <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a>. If no such value has been set (and no error has been set) so that <a class="el" href="classCgu_1_1AsyncResult.html#af5f425d599a8a4343d1642b65f5a346e">is_done()</a> will return false, this method will block until either a value or an error has been set. If an error has been set, this method will return a default constructed object of the template type (and the error can be obtained with <a class="el" href="classCgu_1_1AsyncResult.html#af2c45b2b9b16319c10d35de7a4061727">get_error()</a>). </dd></dl>
<dl class="section note"><dt>Note</dt><dd>Question: Couldn't this method return the stored value by lvalue reference to const? Answer: It could. However, because of return value optimization, which will be implemented by any compiler capable of compiling this library, no advantage would be gained by doing so when initializing a local variable with the return value of this method (the copy constructor will only be called once whether returning by value or const reference). The advantage of returning by value is that the call to the copy constructor is forced to be within the <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">AsyncResult</a> object's mutex, so different threads' calls to the copy constructor are serialized, and also with blocked cancellation, so this method is cancellation safe. All calls to this method by different threads are therefore isolated and we do not have to worry about the thread safety of direct access to the stored value via its const methods outside the mutex (which would not be thread safe if the stored value has data members declared mutable) nor about the cancellation safety of the copy constructor. Of course, for objects which do not have mutable data, a hit arises by returning by value in cases where it is not intended to initialize a local variable at all nor to cancel a thread: where, say, only const methods are to be called on the return value (which could be done directly if this method returned by const reference). However, in many use cases this will be mitigated by the <a class="el" href="classCgu_1_1AsyncResult.html#acc4835c1722a3d5ce0da50ddd91103d1">move_get()</a> method.</dd></dl>
<p>Since 2.0.8 </p>

</div>
</div>
<a class="anchor" id="af2c45b2b9b16319c10d35de7a4061727"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; T &gt;::get_error </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This method is thread safe. It is not a cancellation point. It will not throw. </p>
<dl class="section return"><dt>Returns</dt><dd>the error value set by a call to <a class="el" href="classCgu_1_1AsyncResult.html#aabb4ca29e0367f8e279c8b20be3221e0">set_error()</a>, or 0 if no error has been set.</dd></dl>
<p>Since 2.0.8 </p>

</div>
</div>
<a class="anchor" id="af5f425d599a8a4343d1642b65f5a346e"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; T &gt;::is_done </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This method is thread safe. It is not a cancellation point. It will not throw. </p>
<dl class="section return"><dt>Returns</dt><dd>true if <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a> has been called, or <a class="el" href="classCgu_1_1AsyncResult.html#aabb4ca29e0367f8e279c8b20be3221e0">set_error()</a> has been called with a value other than 0, otherwise false.</dd></dl>
<p>Since 2.0.8 </p>

</div>
</div>
<a class="anchor" id="acc4835c1722a3d5ce0da50ddd91103d1"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">T <a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; T &gt;::move_get </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This method gets the stored value represented by the <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">AsyncResult</a> object by a move operation, if the type of that value implements a move constructor (otherwise this method does the same as the <a class="el" href="classCgu_1_1AsyncResult.html#a8cf43f604c42a48d1a6fa61640c06637">get()</a> method). It is provided as an option for cases where a move is required for efficiency reasons, but although it may be called by any thread, a move operation may normally only be made once (except where the return type has been designed to be moved more than once for the limited purpose of inspecting a flag indicating whether its value is valid or not). If this method is to be called then no calls to <a class="el" href="classCgu_1_1AsyncResult.html#a8cf43f604c42a48d1a6fa61640c06637">get()</a> by another thread should normally be made. This method is a cancellation point if it blocks, and is cancellation safe if the stack unwinds on cancellation. It will not throw unless the copy or move constructor of the return type throws. It is only exception safe if the return type's move constructor is exception safe. </p>
<dl class="section return"><dt>Returns</dt><dd>The value represented by this object as set by a call to <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a>. If no such value has been set (and no error has been set) so that <a class="el" href="classCgu_1_1AsyncResult.html#af5f425d599a8a4343d1642b65f5a346e">is_done()</a> will return false, this method will block until either a value or an error has been set. If an error has been set, until a move operation has been carried out this method will return a default constructed object of the template type (and the error can be obtained with <a class="el" href="classCgu_1_1AsyncResult.html#af2c45b2b9b16319c10d35de7a4061727">get_error()</a>). </dd></dl>
<dl class="section note"><dt>Note</dt><dd>Question: Couldn't this method return the stored value by rvalue reference? Answer: It could. However, because of return value optimization, which will be implemented by any compiler capable of compiling this library, no advantage would be gained by doing so when initializing a local variable with the return value of this method (the move constructor will only be called once, and no call will be made to the copy constructor, whether returning by value or rvalue reference). The advantage of returning by value is that the call to the move constructor is forced to be within the <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">AsyncResult</a> object's mutex, so different threads' calls to the move constructor are serialized, and also with blocked cancellation, so this method is cancellation safe. All calls to this method by different threads are therefore isolated and we do not have to worry about the thread safety of the mutating first call to this method, nor about direct access to the stored value via a rvalue reference outside the mutex nor the cancellation safety of the move constructor.</dd></dl>
<p>Since 2.0.11 </p>

</div>
</div>
<a class="anchor" id="acbcd3f48526999696101b9d012917067"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1AsyncResult.html">AsyncResult</a>&amp; <a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; T &gt;::operator= </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classCgu_1_1AsyncResult.html">AsyncResult</a>&lt; T &gt; &amp;&#160;</td>
          <td class="paramname">)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">delete</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This class cannot be copied. The assignment operator is deleted.</p>
<p>Since 2.0.8 </p>

</div>
</div>
<a class="anchor" id="a3cf99fc76547e0155a2d5d1608c22de7"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; T &gt;::set </td>
          <td>(</td>
          <td class="paramtype">const T &amp;&#160;</td>
          <td class="paramname"><em>val</em>)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This method sets the value represented by the <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">AsyncResult</a> object, provided that <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a> has not previously been called and <a class="el" href="classCgu_1_1AsyncResult.html#aabb4ca29e0367f8e279c8b20be3221e0">set_error()</a> has not previously been called with a value other than 0. If <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a> has previously been called or <a class="el" href="classCgu_1_1AsyncResult.html#aabb4ca29e0367f8e279c8b20be3221e0">set_error()</a> called with a value other than 0 (so that <a class="el" href="classCgu_1_1AsyncResult.html#af5f425d599a8a4343d1642b65f5a346e">is_done()</a> will return true) this method does nothing. It is thread safe. It is not a cancellation point. It will not throw unless the copy assignment operator of the value type throws. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">val</td><td>The value which this object is to represent and which calls to <a class="el" href="classCgu_1_1AsyncResult.html#a8cf43f604c42a48d1a6fa61640c06637">get()</a> or a call to <a class="el" href="classCgu_1_1AsyncResult.html#acc4835c1722a3d5ce0da50ddd91103d1">move_get()</a> will return. Any thread waiting on <a class="el" href="classCgu_1_1AsyncResult.html#a8cf43f604c42a48d1a6fa61640c06637">get()</a> or <a class="el" href="classCgu_1_1AsyncResult.html#acc4835c1722a3d5ce0da50ddd91103d1">move_get()</a> will unblock, and any subsequent calls to <a class="el" href="classCgu_1_1AsyncResult.html#af5f425d599a8a4343d1642b65f5a346e">is_done()</a> will return true. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if the call to this method is effective because <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a> has not previously been called and <a class="el" href="classCgu_1_1AsyncResult.html#aabb4ca29e0367f8e279c8b20be3221e0">set_error()</a> has not previously been called with a value other than 0, otherwise false.</dd></dl>
<p>Since 2.0.8 </p>

</div>
</div>
<a class="anchor" id="ad47b2edf239d0153a84f590798f8ae62"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; T &gt;::set </td>
          <td>(</td>
          <td class="paramtype">T &amp;&amp;&#160;</td>
          <td class="paramname"><em>val</em>)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This method sets the value represented by the <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">AsyncResult</a> object, provided that <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a> has not previously been called and <a class="el" href="classCgu_1_1AsyncResult.html#aabb4ca29e0367f8e279c8b20be3221e0">set_error()</a> has not previously been called with a value other than 0. If <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a> has previously been called or <a class="el" href="classCgu_1_1AsyncResult.html#aabb4ca29e0367f8e279c8b20be3221e0">set_error()</a> called with a value other than 0 (so that <a class="el" href="classCgu_1_1AsyncResult.html#af5f425d599a8a4343d1642b65f5a346e">is_done()</a> will return true) this method does nothing. It is thread safe. It is not a cancellation point. It will not throw unless the copy or move assignment operator of the value type throws. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">val</td><td>The value which this object is to represent and which calls to <a class="el" href="classCgu_1_1AsyncResult.html#a8cf43f604c42a48d1a6fa61640c06637">get()</a> or a call to <a class="el" href="classCgu_1_1AsyncResult.html#acc4835c1722a3d5ce0da50ddd91103d1">move_get()</a> will return. Any thread waiting on <a class="el" href="classCgu_1_1AsyncResult.html#a8cf43f604c42a48d1a6fa61640c06637">get()</a> or <a class="el" href="classCgu_1_1AsyncResult.html#acc4835c1722a3d5ce0da50ddd91103d1">move_get()</a> will unblock, and any subsequent calls to <a class="el" href="classCgu_1_1AsyncResult.html#af5f425d599a8a4343d1642b65f5a346e">is_done()</a> will return true. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if the call to this method is effective because <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a> has not previously been called and <a class="el" href="classCgu_1_1AsyncResult.html#aabb4ca29e0367f8e279c8b20be3221e0">set_error()</a> has not previously been called with a value other than 0, otherwise false.</dd></dl>
<p>Since 2.0.8 </p>

</div>
</div>
<a class="anchor" id="aabb4ca29e0367f8e279c8b20be3221e0"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; T &gt;::set_error </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>err</em> = <code>-1</code>)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This method sets an error if called with a value other than 0, provided that <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a> has not previously been called and this method has not previously been called with a value other than 0. If <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a> has been called or this method previously called with a value other than 0 (so that <a class="el" href="classCgu_1_1AsyncResult.html#af5f425d599a8a4343d1642b65f5a346e">is_done()</a> will return true), this method does nothing. This method is thread safe. It is not a cancellation point. It will not throw. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">err</td><td>The value which subsequent calls to <a class="el" href="classCgu_1_1AsyncResult.html#af2c45b2b9b16319c10d35de7a4061727">get_error()</a> will report. If the value of err is 0, or if this method has been called with a value other than 0 or <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a> has previously been called, this method will do nothing. Otherwise, any thread waiting on <a class="el" href="classCgu_1_1AsyncResult.html#a8cf43f604c42a48d1a6fa61640c06637">get()</a> or <a class="el" href="classCgu_1_1AsyncResult.html#acc4835c1722a3d5ce0da50ddd91103d1">move_get()</a> will unblock (they will return a default constructed object of the template type), and any subsequent calls to <a class="el" href="classCgu_1_1AsyncResult.html#af5f425d599a8a4343d1642b65f5a346e">is_done()</a> will return true. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if the call to this method is effective because the error value passed is not 0, <a class="el" href="classCgu_1_1AsyncResult.html#a3cf99fc76547e0155a2d5d1608c22de7">set()</a> has not previously been called and this method has not previously been called with a value other than 0, otherwise false.</dd></dl>
<p>Since 2.0.8 </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="async__result_8h_source.html">async_result.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Mon Sep 16 2013 20:45:31 for c++-gtk-utils by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.4
</small></address>
</body>
</html>