• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<head>
4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5<title>Class mutex</title>
6<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
8<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
9<link rel="up" href="../../signals2/reference.html#header.boost.signals2.mutex_hpp" title="Header &lt;boost/signals2/mutex.hpp&gt;">
10<link rel="prev" href="no_slots_error.html" title="Class no_slots_error">
11<link rel="next" href="optional_last_value.html" title="Class template optional_last_value">
12</head>
13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14<table cellpadding="2" width="100%"><tr>
15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
16<td align="center"><a href="../../../../index.html">Home</a></td>
17<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
20<td align="center"><a href="../../../../more/index.htm">More</a></td>
21</tr></table>
22<hr>
23<div class="spirit-nav">
24<a accesskey="p" href="no_slots_error.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../signals2/reference.html#header.boost.signals2.mutex_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="optional_last_value.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
25</div>
26<div class="refentry">
27<a name="boost.signals2.mutex"></a><div class="titlepage"></div>
28<div class="refnamediv">
29<h2><span class="refentrytitle">Class mutex</span></h2>
30<p>boost::signals2::mutex — A header-only mutex which implements the Lockable concept of Boost.Thread.</p>
31</div>
32<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
33<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../signals2/reference.html#header.boost.signals2.mutex_hpp" title="Header &lt;boost/signals2/mutex.hpp&gt;">boost/signals2/mutex.hpp</a>&gt;
34
35</span>
36<span class="keyword">class</span> <a class="link" href="mutex.html" title="Class mutex">mutex</a> <span class="special">{</span>
37<span class="keyword">public</span><span class="special">:</span>
38  <span class="keyword">void</span> <a class="link" href="mutex.html#id-1_3_36_6_6_3_1_1_3_1-bb"><span class="identifier">lock</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
39  <span class="keyword">bool</span> <a class="link" href="mutex.html#id-1_3_36_6_6_3_1_1_3_2-bb"><span class="identifier">try_lock</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
40  <span class="keyword">void</span> <a class="link" href="mutex.html#id-1_3_36_6_6_3_1_1_3_3-bb"><span class="identifier">unlock</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
41<span class="special">}</span><span class="special">;</span></pre></div>
42<div class="refsect1">
43<a name="id-1.3.36.6.7.3.4"></a><h2>Description</h2>
44<p>
45            The <code class="computeroutput">mutex</code> class implements the <code class="computeroutput">Lockable</code>
46            concept of Boost.Thread, and is the default <code class="computeroutput">Mutex</code> template parameter
47            type for signals.
48            If boost has detected thread support in your compiler, the <code class="computeroutput">mutex</code>
49            class will map to a CRITICAL_SECTION on Windows
50            or a pthread_mutex on POSIX.  If thread support is not detected, <code class="computeroutput">mutex</code>
51            will behave similarly to a <a class="link" href="dummy_mutex.html" title="Class dummy_mutex">dummy_mutex</a>.
52            The header file <code class="computeroutput">boost/config.hpp</code>
53            defines the macro <code class="computeroutput">BOOST_HAS_THREADS</code> when boost detects threading support.
54            The user may globally disable thread support
55            in boost by defining BOOST_DISABLE_THREADS before any boost header files are included.
56          </p>
57<p>
58            If you are already using the Boost.Thread library, you may prefer to use its
59            boost::mutex class instead as the mutex type for your signals.
60          </p>
61<p>
62            You may wish to use a thread-unsafe signal, if
63            the signal is only used by a single thread.  In that case, you may prefer to
64            use the <a class="link" href="dummy_mutex.html" title="Class dummy_mutex">signals2::dummy_mutex</a> class as the <code class="computeroutput">Mutex</code>
65            template type for your signal.
66          </p>
67<pre class="literallayout"><span class="keyword">void</span> <a name="id-1_3_36_6_6_3_1_1_3_1-bb"></a><span class="identifier">lock</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
68<p>Locks the mutex.
69              </p>
70<pre class="literallayout"><span class="keyword">bool</span> <a name="id-1_3_36_6_6_3_1_1_3_2-bb"></a><span class="identifier">try_lock</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
71<p>Makes a non-blocking attempt to lock the mutex.
72              </p>
73<div class="variablelist"><table border="0" class="variablelist compact">
74<colgroup>
75<col align="left" valign="top">
76<col>
77</colgroup>
78<tbody><tr>
79<td><p><span class="term">Returns:</span></p></td>
80<td><p><code class="computeroutput">true</code> on success.</p></td>
81</tr></tbody>
82</table></div>
83<pre class="literallayout"><span class="keyword">void</span> <a name="id-1_3_36_6_6_3_1_1_3_3-bb"></a><span class="identifier">unlock</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
84<p>Unlocks the mutex.
85              </p>
86</div>
87</div>
88<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
89<td align="left"></td>
90<td align="right"><div class="copyright-footer">Copyright © 2001-2004 Douglas Gregor<br>Copyright © 2007-2009 Frank Mori Hess<p>Distributed under the Boost
91    Software License, Version 1.0. (See accompanying file
92    <code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
93</div></td>
94</tr></table>
95<hr>
96<div class="spirit-nav">
97<a accesskey="p" href="no_slots_error.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../signals2/reference.html#header.boost.signals2.mutex_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="optional_last_value.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
98</div>
99</body>
100</html>
101