Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/pool/doc/implementation/mutex.html @ 29

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

updated boost from 1_33_1 to 1_34_1

File size: 4.5 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2"http://www.w3.org/TR/html4/loose.dtd">
3
4<html>
5<head>
6  <meta http-equiv="Content-Language" content="en-us">
7  <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
8  <link href="../pool.css" rel="stylesheet" type="text/css">
9
10  <title>mutex - Mutex</title>
11</head>
12
13<body>
14  <img src="../../../../boost.png" width="276" height="86" alt="C++ Boost">
15
16  <h1 align="center">mutex - Mutex</h1>
17
18  <h2>Introduction</h2>
19
20  <p>detail/mutex.hpp provides several mutex types that provide a consistent
21  interface for OS-supplied mutex types. These are all thread-level mutexes;
22  interprocess mutexes are not supported.</p>
23
24  <h2>Configuration</h2>
25
26  <p>This header file will try to guess what kind of system it is on. It will
27  auto-configure itself for Win32 or POSIX+pthread systems. To stub out all
28  mutex code, bypassing the auto-configuration, <span class="code">#define
29  BOOST_NO_MT</span> before any inclusion of this header. To prevent ODR
30  violations, this should be defined in <strong>every</strong> translation
31  unit in your project, including any library files.</p>
32
33  <h2>Synopsis</h2>
34  <pre class="code">
35namespace details {
36namespace pool {
37
38// Only present if on a Win32 system
39class Win32_mutex
40{
41  private:
42    Win32_mutex(const Win32_mutex &amp;);
43    void operator=(const Win32_mutex &amp;);
44
45  public:
46    Win32_mutex();
47    ~Win32_mutex();
48
49    void lock();
50    void unlock();
51};
52
53// Only present if on a POSIX+pthread system
54class pthread_mutex
55{
56  private:
57    pthread_mutex(const pthread_mutex &amp;);
58    void operator=(const pthread_mutex &amp;);
59
60  public:
61    pthread_mutex();
62    ~pthread_mutex();
63
64    void lock();
65    void unlock();
66};
67
68// Present on all systems
69class null_mutex
70{
71  private:
72    null_mutex(const null_mutex &amp;);
73    void operator=(const null_mutex &amp;);
74
75  public:
76    null_mutex();
77    ~null_mutex();
78
79    static void lock();
80    static void unlock();
81};
82
83// This will be one of the types above
84typedef ... default_mutex;
85
86} // namespace pool
87} // namespace details
88</pre>
89
90  <h2>Semantics</h2>
91
92  <table border align="center" summary="">
93    <caption>
94      <em>Symbol Table</em>
95    </caption>
96
97    <tr>
98      <th>Symbol</th>
99
100      <th>Meaning</th>
101    </tr>
102
103    <tr>
104      <td class="code">Mutex</td>
105
106      <td>Any type defined in this header</td>
107    </tr>
108
109    <tr>
110      <td class="code">t</td>
111
112      <td>value of type <span class="code">Mutex</span></td>
113    </tr>
114  </table><br>
115
116  <table border align="center" summary="">
117    <caption>
118      <em>Requirements satisfied by <span class="code">mutex</span></em>
119    </caption>
120
121    <tr>
122      <th>Expression</th>
123
124      <th>Return Type</th>
125
126      <th>Assertion/Note/Pre/Post-Condition</th>
127    </tr>
128
129    <tr>
130      <td class="code">m.lock()</td>
131
132      <td>not used</td>
133
134      <td>Locks the mutex</td>
135    </tr>
136
137    <tr>
138      <td class="code">m.unlock()</td>
139
140      <td>not used</td>
141
142      <td>Unlocks the mutex</td>
143    </tr>
144  </table>
145
146  <p>Each mutex is always either owned or unowned. If owned, then it is owned
147  by a particular thread. To "lock" a mutex means to wait until the mutex is
148  unowned, and then make it owned by the current thread. To "unlock" a mutex
149  means to release ownership from the current thread (note that the current
150  thread <strong>must</strong> own the mutex to release that ownership!). As
151  a special case, the <span class="code">null_mutex</span> never waits.</p>
152
153  <h2>Dependencies</h2>
154
155  <p>May include the system headers <span class=
156  "code">&lt;windows.h&gt;</span>, <span class=
157  "code">&lt;unistd.h&gt;</span>, and/or <span class=
158  "code">&lt;pthread.h&gt;</span>.</p>
159
160  <h2>Future Directions</h2>
161
162  <p>This header will eventually be replaced by a Boost multithreading
163  library.</p>
164  <hr>
165
166  <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
167  "http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional"
168  height="31" width="88"></a></p>
169
170  <p>Revised
171  <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05
172  December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>
173
174  <p><i>Copyright &copy; 2000, 2001 Stephen Cleary (scleary AT jerviswebb DOT
175  com)</i></p>
176
177  <p><i>Distributed under the Boost Software License, Version 1.0. (See
178  accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a>
179  or copy at <a href=
180  "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
181</body>
182</html>
Note: See TracBrowser for help on using the repository browser.