MUtilities/docs/d0/dce/class_m_utils_1_1_lazy.html

111 lines
7.3 KiB
HTML

<!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.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MuldeR&#39;s Utilities for Qt: MUtils::Lazy&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="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.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 id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">MuldeR&#39;s Utilities for Qt
</div>
<div id="projectbrief">MUtilities</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('../../',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="../../d3/da6/namespace_m_utils.html">MUtils</a></li><li class="navelem"><a class="el" href="../../d0/dce/class_m_utils_1_1_lazy.html">Lazy</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="../../da/d44/class_m_utils_1_1_lazy-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">MUtils::Lazy&lt; T &gt; Class Template Reference<span class="mlabels"><span class="mlabel">abstract</span></span></div> </div>
</div><!--header-->
<div class="contents">
<p><a class="el" href="../../d0/dce/class_m_utils_1_1_lazy.html" title="Lazy initialization template class. ">Lazy</a> initialization template class.
<a href="../../d0/dce/class_m_utils_1_1_lazy.html#details">More...</a></p>
<p><code>#include &lt;<a class="el" href="../../d8/d4d/_lazy_8h_source.html">Lazy.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:a86cf7d344a38ea09d37d27acd8993f45"><td class="memItemLeft" align="right" valign="top"><a id="a86cf7d344a38ea09d37d27acd8993f45"></a>
T &amp;&#160;</td><td class="memItemRight" valign="bottom"><b>operator*</b> (void)</td></tr>
<tr class="separator:a86cf7d344a38ea09d37d27acd8993f45"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:a03f52adf0e421b20298f2f7578e3375f"><td class="memItemLeft" align="right" valign="top"><a id="a03f52adf0e421b20298f2f7578e3375f"></a>
virtual T *&#160;</td><td class="memItemRight" valign="bottom"><b>create</b> ()=0</td></tr>
<tr class="separator:a03f52adf0e421b20298f2f7578e3375f"><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;typename T&gt;<br />
class MUtils::Lazy&lt; T &gt;</h3>
<p><a class="el" href="../../d0/dce/class_m_utils_1_1_lazy.html" title="Lazy initialization template class. ">Lazy</a> initialization template class. </p>
<p>In order to create your own "lazy" initializer, inherit from the <code><a class="el" href="../../d0/dce/class_m_utils_1_1_lazy.html" title="Lazy initialization template class. ">Lazy</a>&lt;T&gt;</code> class an implement the <a class="el" href="../../d2/dad/_hash_8h.html#a330b73d6927d6cd95892712f9396f40e" title="Create instance of a hash function. ">create()</a> function. The lazy-initialized value can be obtained from a <code><a class="el" href="../../d0/dce/class_m_utils_1_1_lazy.html" title="Lazy initialization template class. ">Lazy</a>&lt;T&gt;</code> instance by using the <code>operator*()</code>. Initialization of the value happens when the <code>operator*()</code> is called for the very first time, by invoking the concrete <a class="el" href="../../d2/dad/_hash_8h.html#a330b73d6927d6cd95892712f9396f40e" title="Create instance of a hash function. ">create()</a> function. The return value of <a class="el" href="../../d2/dad/_hash_8h.html#a330b73d6927d6cd95892712f9396f40e" title="Create instance of a hash function. ">create()</a> is then stored internally, so that any subsequent call to the <code>operator*()</code> immediately returns the previously created value.</p>
<p><b>Note on thread-saftey:</b> This class is thread-safe in the sense that all calls to <code>operator*()</code> on the same <code><a class="el" href="../../d0/dce/class_m_utils_1_1_lazy.html" title="Lazy initialization template class. ">Lazy</a>&lt;T&gt;</code> instance, regardless from which thread, are guaranteed to return the exactly same value/object. Still, if the value has <em>not</em> been initialized yet <b>and</b> if multiple threads happen to call <code>operator*()</code> at the same time, then the concrete <a class="el" href="../../d2/dad/_hash_8h.html#a330b73d6927d6cd95892712f9396f40e" title="Create instance of a hash function. ">create()</a> function <em>may</em> be invoked more than once (concurrently and by different threads). In that case, all but one return value of <a class="el" href="../../d2/dad/_hash_8h.html#a330b73d6927d6cd95892712f9396f40e" title="Create instance of a hash function. ">create()</a> are discarded, and all threads eventually receive the same value/object. </p>
</div><hr/>The documentation for this class was generated from the following file:<ul>
<li>include/MUtils/<a class="el" href="../../d8/d4d/_lazy_8h_source.html">Lazy.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/>
</a> 1.8.12
</small></address>
</body>
</html>