File: classwx_critical_section.html

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (193 lines) | stat: -rw-r--r-- 13,054 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!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"/>
<title>wxWidgets: wxCriticalSection Class 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="doxygen.css" rel="stylesheet" type="text/css" />
<link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="page_container">
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0" style="width: 100%;">
 <tbody>
 <tr>
  <td id="projectlogo">
    <a href="http://www.wxwidgets.org/" target="_new">
      <img alt="wxWidgets" src="logo.png"/>
    </a>
  </td>
  <td style="padding-left: 0.5em; text-align: right;">
   <span id="projectnumber">Version: 3.0.2</span>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- Generated by Doxygen 1.8.2 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Categories</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classwx_critical_section-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">wxCriticalSection Class Reference<div class="ingroups"><a class="el" href="group__group__class__threading.html">Threading</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p><code>#include &lt;wx/thread.h&gt;</code></p>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>A critical section object is used for exactly the same purpose as a <a class="el" href="classwx_mutex.html" title="A mutex object is a synchronization object whose state is set to signaled when it is not owned by any...">wxMutex</a>. </p>
<p>The only difference is that under Windows platform critical sections are only visible inside one process, while mutexes may be shared among processes, so using critical sections is slightly more efficient.</p>
<p>The terminology is also slightly different: mutex may be locked (or acquired) and unlocked (or released) while critical section is entered and left by the program.</p>
<p>Finally, you should try to use <a class="el" href="classwx_critical_section_locker.html" title="This is a small helper class to be used with wxCriticalSection objects.">wxCriticalSectionLocker</a> class whenever possible instead of directly using <a class="el" href="classwx_critical_section.html" title="A critical section object is used for exactly the same purpose as a wxMutex.">wxCriticalSection</a> for the same reasons <a class="el" href="classwx_mutex_locker.html" title="This is a small helper class to be used with wxMutex objects.">wxMutexLocker</a> is preferable to <a class="el" href="classwx_mutex.html" title="A mutex object is a synchronization object whose state is set to signaled when it is not owned by any...">wxMutex</a> - please see <a class="el" href="classwx_mutex.html" title="A mutex object is a synchronization object whose state is set to signaled when it is not owned by any...">wxMutex</a> for an example.</p>
<h2></h2>
<div><span class="lib">Library:</span>&#160;&#160;<span class="lib_text"><a class="el" href="page_libs.html#page_libs_wxbase">wxBase</a></span></div><div><span class="category">Category:</span>&#160;&#160;<span class="category_text"><a class="el" href="group__group__class__threading.html">Threading</a></span></div><dl class="section note"><dt>Note</dt><dd>Critical sections can be used before the wxWidgets library is fully initialized. In particular, it's safe to create global <a class="el" href="classwx_critical_section.html" title="A critical section object is used for exactly the same purpose as a wxMutex.">wxCriticalSection</a> instances.</dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classwx_thread.html" title="A thread is basically a path of execution through a program.">wxThread</a>, <a class="el" href="classwx_condition.html" title="wxCondition variables correspond to pthread conditions or to Win32 event objects.">wxCondition</a>, <a class="el" href="classwx_critical_section_locker.html" title="This is a small helper class to be used with wxCriticalSection objects.">wxCriticalSectionLocker</a> </dd></dl>
</div><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:a483f17efa8bb35b3829288165bb2dedc"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_critical_section.html#a483f17efa8bb35b3829288165bb2dedc">wxCriticalSection</a> (<a class="el" href="interface_2wx_2thread_8h.html#ad32912ed5726dfd2d4c24bdafbedac2e">wxCriticalSectionType</a> critSecType=<a class="el" href="interface_2wx_2thread_8h.html#ad32912ed5726dfd2d4c24bdafbedac2eaedf8cd97bb2d9cf66c6fa04c83ef15ce">wxCRITSEC_DEFAULT</a>)</td></tr>
<tr class="memdesc:a483f17efa8bb35b3829288165bb2dedc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default constructor initializes critical section object.  <a href="#a483f17efa8bb35b3829288165bb2dedc"></a><br/></td></tr>
<tr class="separator:a483f17efa8bb35b3829288165bb2dedc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6701aa3a4d56438728d0a2511c264d30"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_critical_section.html#a6701aa3a4d56438728d0a2511c264d30">~wxCriticalSection</a> ()</td></tr>
<tr class="memdesc:a6701aa3a4d56438728d0a2511c264d30"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destructor frees the resources.  <a href="#a6701aa3a4d56438728d0a2511c264d30"></a><br/></td></tr>
<tr class="separator:a6701aa3a4d56438728d0a2511c264d30"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afa80c7cb306d72884ebcc4e60ea61d39"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_critical_section.html#afa80c7cb306d72884ebcc4e60ea61d39">Enter</a> ()</td></tr>
<tr class="memdesc:afa80c7cb306d72884ebcc4e60ea61d39"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enter the critical section (same as locking a mutex): if another thread has already entered it, this call will block until the other thread calls <a class="el" href="classwx_critical_section.html#a9710ab7240b29a653fd9233c12aadba6" title="Leave the critical section allowing other threads use the global data protected by it...">Leave()</a>.  <a href="#afa80c7cb306d72884ebcc4e60ea61d39"></a><br/></td></tr>
<tr class="separator:afa80c7cb306d72884ebcc4e60ea61d39"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abb732e66f2b0e6f38d30f29a25d8851a"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_critical_section.html#abb732e66f2b0e6f38d30f29a25d8851a">TryEnter</a> ()</td></tr>
<tr class="memdesc:abb732e66f2b0e6f38d30f29a25d8851a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Try to enter the critical section (same as trying to lock a mutex).  <a href="#abb732e66f2b0e6f38d30f29a25d8851a"></a><br/></td></tr>
<tr class="separator:abb732e66f2b0e6f38d30f29a25d8851a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9710ab7240b29a653fd9233c12aadba6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_critical_section.html#a9710ab7240b29a653fd9233c12aadba6">Leave</a> ()</td></tr>
<tr class="memdesc:a9710ab7240b29a653fd9233c12aadba6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Leave the critical section allowing other threads use the global data protected by it.  <a href="#a9710ab7240b29a653fd9233c12aadba6"></a><br/></td></tr>
<tr class="separator:a9710ab7240b29a653fd9233c12aadba6"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a483f17efa8bb35b3829288165bb2dedc"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">wxCriticalSection::wxCriticalSection </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="interface_2wx_2thread_8h.html#ad32912ed5726dfd2d4c24bdafbedac2e">wxCriticalSectionType</a>&#160;</td>
          <td class="paramname"><em>critSecType</em> = <code><a class="el" href="interface_2wx_2thread_8h.html#ad32912ed5726dfd2d4c24bdafbedac2eaedf8cd97bb2d9cf66c6fa04c83ef15ce">wxCRITSEC_DEFAULT</a></code></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Default constructor initializes critical section object. </p>
<p>By default critical sections are recursive under Unix and Windows. </p>

</div>
</div>
<a class="anchor" id="a6701aa3a4d56438728d0a2511c264d30"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">wxCriticalSection::~wxCriticalSection </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Destructor frees the resources. </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="afa80c7cb306d72884ebcc4e60ea61d39"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void wxCriticalSection::Enter </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Enter the critical section (same as locking a mutex): if another thread has already entered it, this call will block until the other thread calls <a class="el" href="classwx_critical_section.html#a9710ab7240b29a653fd9233c12aadba6" title="Leave the critical section allowing other threads use the global data protected by it...">Leave()</a>. </p>
<p>There is no error return for this function.</p>
<p>After entering the critical section protecting a data variable, the thread running inside the critical section may safely use/modify it.</p>
<p>Note that entering the same critical section twice or more from the same thread doesn't result in a deadlock; in this case in fact this function will immediately return. </p>

</div>
</div>
<a class="anchor" id="a9710ab7240b29a653fd9233c12aadba6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void wxCriticalSection::Leave </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Leave the critical section allowing other threads use the global data protected by it. </p>
<p>There is no error return for this function. </p>

</div>
</div>
<a class="anchor" id="abb732e66f2b0e6f38d30f29a25d8851a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool wxCriticalSection::TryEnter </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Try to enter the critical section (same as trying to lock a mutex). </p>
<p>If it can't, immediately returns false.</p>
<dl class="section since"><dt>Since</dt><dd>2.9.3 </dd></dl>

</div>
</div>
</div><!-- contents -->

<address class="footer">
	<small>
		Generated on Thu Nov 27 2014 13:46:45 for wxWidgets by <a href="http://www.doxygen.org/index.html" target="_new">Doxygen</a> 1.8.2
	</small>
</address>
<script src="wxwidgets.js" type="text/javascript"></script>
</div><!-- #page_container -->
</body>
</html>