File: group__group__funcmacro__atomic.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 (117 lines) | stat: -rw-r--r-- 6,998 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
<!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: Atomic Operations</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><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Atomic Operations</div>  </div>
<div class="ingroups"><a class="el" href="group__group__funcmacro.html">Functions and Macros by Category</a></div></div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>When using multi-threaded applications, it is often required to access or modify memory which is shared between threads. </p>
<p>Atomic integer and pointer operations are an efficient way to handle this issue (another, less efficient, way is to use 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> or <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>). A native implementation exists for Windows, Linux, Solaris and Mac OS X; for others, a <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> is used to protect the data.</p>
<p>One particular application is reference counting (used by so-called <a class="el" href="group__group__class__smartpointers.html">smart pointers</a>).</p>
<p>You should define your variable with the type wxAtomicInt in order to apply atomic operations to it. </p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga35470b5fc125b443e73b7967100752d4"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__funcmacro__atomic.html#ga35470b5fc125b443e73b7967100752d4">wxAtomicInc</a> (wxAtomicInt &amp;value)</td></tr>
<tr class="memdesc:ga35470b5fc125b443e73b7967100752d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function increments <em>value</em> in an atomic manner.  <a href="#ga35470b5fc125b443e73b7967100752d4"></a><br/></td></tr>
<tr class="separator:ga35470b5fc125b443e73b7967100752d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga396a0a6c5b705d46862564f5b16897b2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="defs_8h.html#a5c084575ef1ffaa7586dda7e4b22d78a">wxInt32</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__funcmacro__atomic.html#ga396a0a6c5b705d46862564f5b16897b2">wxAtomicDec</a> (wxAtomicInt &amp;value)</td></tr>
<tr class="memdesc:ga396a0a6c5b705d46862564f5b16897b2"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function decrements value in an atomic manner.  <a href="#ga396a0a6c5b705d46862564f5b16897b2"></a><br/></td></tr>
<tr class="separator:ga396a0a6c5b705d46862564f5b16897b2"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga396a0a6c5b705d46862564f5b16897b2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="defs_8h.html#a5c084575ef1ffaa7586dda7e4b22d78a">wxInt32</a> wxAtomicDec </td>
          <td>(</td>
          <td class="paramtype">wxAtomicInt &amp;&#160;</td>
          <td class="paramname"><em>value</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function decrements value in an atomic manner. </p>
<p>Returns 0 if value is 0 after decrement or any non-zero value (not necessarily equal to the value of the variable) otherwise.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="group__group__funcmacro__atomic.html#ga35470b5fc125b443e73b7967100752d4" title="This function increments value in an atomic manner.">wxAtomicInc</a></dd></dl>
<p>Include file: </p>
<pre class="fragment">#include &lt;wx/atomic.h&gt; </pre> 
</div>
</div>
<a class="anchor" id="ga35470b5fc125b443e73b7967100752d4"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void wxAtomicInc </td>
          <td>(</td>
          <td class="paramtype">wxAtomicInt &amp;&#160;</td>
          <td class="paramname"><em>value</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function increments <em>value</em> in an atomic manner. </p>
<p>Whenever possible wxWidgets provides an efficient, CPU-specific, implementation of this function. If such implementation is available, the symbol wxHAS_ATOMIC_OPS is defined. Otherwise this function still exists but is implemented in a generic way using a critical section which can be prohibitively expensive for use in performance-sensitive code.</p>
<p>Include file: </p>
<pre class="fragment">#include &lt;wx/atomic.h&gt; </pre> 
</div>
</div>
</div><!-- contents -->

<address class="footer">
	<small>
		Generated on Thu Nov 27 2014 13:46:43 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>