Sophie

Sophie

distrib > Mandriva > 10.0 > i586 > by-pkgid > ef9bad9e14fc2a68cb7c992c11d75f5e > files > 4219

libboost1-devel-1.31.0-1mdk.i586.rpm

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
<title>Boost.Threads - Header &lt;boost/thread/once.hpp&gt;</title>
</head>
<body link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
    "header">
  <tr>
    <td valign="top" width="300">
      <h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
    </td>
    <td valign="top">
      <h1 align="center">Boost.Threads</h1>
      <h2 align="center">Header &lt;<a href="../../../boost/thread/once.hpp">boost/thread/once.hpp</a>&gt;</h2>
    </td>
  </tr>
</table>
<hr>
<h2>Contents</h2>
<dl class="page-index">
  <dt><a href="#introduction">Introduction</a></dt>
  <dt><a href="#macros">Macros</a></dt>
  <dl class="page-index">
    <dt><a href="#macro-BOOST_ONCE_INIT">BOOST_ONCE_INIT</a></dt>
  </dl>
  <dt><a href="#types">Types</a></dt>
  <dl class="page-index">
    <dt><a href="#type-once_flag">once_flag</a></dt>
  </dl>
  <dt><a href="#functions">Functions</a></dt>
  <dl class="page-index">
    <dt><a href="#function-call_once">call_once</a></dt>
  </dl>
  <dt><a href="#examples">Example(s)</a></dt>
</dl>
<hr>
<h2><a name="introduction"></a>Introduction</h2>
<p>Include the header &lt;<a href="../../../boost/thread/once.hpp">boost/thread/once.hpp</a>&gt;
  to define the <code>call_once</code> function, <code>once_flag</code> type and
  <code>BOOST_ONCE_INIT</code> constant.</p>
<p>The <code>call_once</code> function and <code>once_flag</code> type (statically
  initialized to <code>BOOST_ONCE_INIT</code>) can be used to run a routine exactly
  once. This can be used to initialize data in a <a href="definitions.html#Thread-safe">
  thread-safe</a> manner.</p>
<h2><a name="macros"></a>Macros</h2>
<pre>
<a name="macro-BOOST_ONCE_INIT"></a>#define BOOST_ONCE_INIT <i>implementation defined</i>
</pre>
<p>This is a constant value used to initialize <code>once_flag</code> instances
  to indicate that the logically associated routine has not been run yet.</p>
<h2><a name="types"></a>Types</h2>
<pre>
<a name="type-once_flag"></a>typedef <i>implementation defined</i> once_flag;
</pre>
<p>This implementation defined type is used as a flag to insure a routine is called
  only once. Instances of this type should be statically initialized to <code>BOOST_ONCE_INIT</code>.</p>
<h2><a name="functions"></a>Functions</h2>
<pre>
<a name="function-call_once"></a>void call_once(void (*func)(), once_flag& flag);
</pre>
<dl class="function-semantics">
  <dt><b>Requires:</b> The function <code>func</code> shall not throw exceptions.</dt>
  <dt><b>Effects:</b> As if (in an atomic fashion):
    <pre>
if (flag == BOOST_ONCE_INIT)
    func();
</pre>
  </dt>
  <dt><b>Postconditions:</b> <code>flag != BOOST_ONCE_INIT</code></dt>
</dl>
<h2><a name="examples"></a>Example(s)</h2>
<p><a href="../example/once.cpp">libs/thread/example/once.cpp</a></p>
<hr>
<p>Revised
  <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
  05 November, 2001
  <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p><i>&copy; Copyright <a href="mailto:wekempf@cox.net">William E. Kempf</a> 2001-2002.
  All Rights Reserved.</i></p>
<p>Permission to use, copy, modify, distribute and sell this software and its
  documentation for any purpose is hereby granted without fee, provided that the
  above copyright notice appear in all copies and that both that copyright notice
  and this permission notice appear in supporting documentation. William E. Kempf
  makes no representations about the suitability of this software for any purpose.
  It is provided &quot;as is&quot; without express or implied warranty.</p>
</body>
</html>