Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/doc/html/call_once.html @ 25

Last change on this file since 25 was 12, checked in by landauf, 17 years ago

added boost

File size: 3.9 KB
Line 
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4<title>Function call_once</title>
5<link rel="stylesheet" href="boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
7<link rel="start" href="index.html" title="The Boost C++ Libraries">
8<link rel="up" href="threads/reference.html#id2534986" title="Header &lt;boost/thread/once.hpp&gt;">
9<link rel="prev" href="BOOST_ONCE_INIT.html" title="Macro BOOST_ONCE_INIT">
10<link rel="next" href="recursive_mutex.html" title="Class recursive_mutex">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%">
14<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../boost.png"></td>
15<td align="center"><a href="../../index.htm">Home</a></td>
16<td align="center"><a href="../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="../../people/people.htm">People</a></td>
18<td align="center"><a href="../../more/faq.htm">FAQ</a></td>
19<td align="center"><a href="../../more/index.htm">More</a></td>
20</table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="BOOST_ONCE_INIT.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="threads/reference.html#id2534986"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="recursive_mutex.html"><img src="images/next.png" alt="Next"></a>
24</div>
25<div class="refentry" lang="en">
26<a name="call_once"></a><div class="titlepage"></div>
27<div class="refnamediv">
28<h2><span class="refentrytitle">Function call_once</span></h2>
29<p>boost::call_once &#8212; The <a href="call_once.html" title="Function call_once">call_once</a> function and
30                        <code class="computeroutput">once_flag</code> type (statically initialized to
31                        <a href="BOOST_ONCE_INIT.html" title="Macro BOOST_ONCE_INIT">BOOST_ONCE_INIT</a>) can be used to run a
32                        routine exactly once. This can be used to initialize data in a
33                        <a href="threads.html#threads.glossary.thread-safe">thread-safe</a>
34                        manner.</p>
35</div>
36<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
37<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis">
38 call_once(<span class="bold"><strong>void</strong></span> (*func)() func, once_flag&amp; flag);</pre></div>
39<div class="refsect1" lang="en">
40<a name="id2782216"></a><h2>Description</h2>
41<p>Example usage is as follows:</p>
42<pre class="programlisting">//Example usage:
43boost::once_flag once = BOOST_ONCE_INIT;
44
45void init()
46{
47    //...
48}
49
50void thread_proc()
51{
52    boost::call_once(&amp;init, once);
53}</pre>
54<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Requires</span></b>:
55
56    The function <code class="computeroutput">func</code> shall not throw
57                        exceptions.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>:
58
59    As if (in an atomic fashion):
60                        <code class="computeroutput">if (flag == BOOST_ONCE_INIT) func();</code><br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Postconditions</span></b>:
61
62    <code class="computeroutput">flag != BOOST_ONCE_INIT</code></p>
63</div>
64</div>
65<table width="100%"><tr>
66<td align="left"></td>
67<td align="right"><small>Copyright © 2001-2003 William E. Kempf</small></td>
68</tr></table>
69<hr>
70<div class="spirit-nav">
71<a accesskey="p" href="BOOST_ONCE_INIT.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="threads/reference.html#id2534986"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="recursive_mutex.html"><img src="images/next.png" alt="Next"></a>
72</div>
73</body>
74</html>
Note: See TracBrowser for help on using the repository browser.