<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>mrpt::synch::CCriticalSectionLocker Class Reference</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <div align="left"><a href="http://www.mrpt.org/">Main MRPT website</a> > <b>C++ reference</b> </div> <div align="right"> <a href="index.html"><img border="0" src="mrpt_logo.png" alt="MRPT logo"></a> </div> <!-- Generated by Doxygen 1.7.5 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</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> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <div class="left"> <form id="FSearchBox" action="search.php" method="get"> <img id="MSearchSelect" src="search/mag.png" alt=""/> <input type="text" id="MSearchField" name="query" value="Search" size="20" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)"/> </form> </div><div class="right"></div> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="classes.html"><span>Class Index</span></a></li> <li><a href="inherits.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="namespacemrpt.html">mrpt</a> </li> <li class="navelem"><a class="el" href="namespacemrpt_1_1synch.html">synch</a> </li> <li class="navelem"><a class="el" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html">CCriticalSectionLocker</a> </li> </ul> </div> </div> <div class="header"> <div class="summary"> <a href="#pub-methods">Public Member Functions</a> | <a href="#pro-attribs">Protected Attributes</a> </div> <div class="headertitle"> <div class="title">mrpt::synch::CCriticalSectionLocker Class Reference</div> </div> </div> <div class="contents"> <!-- doxytag: class="mrpt::synch::CCriticalSectionLocker" --><hr/><a name="details" id="details"></a><h2>Detailed Description</h2> <div class="textblock"><p>A class acquiring a <a class="el" href="classmrpt_1_1synch_1_1_c_critical_section.html" title="This class provides simple critical sections functionality.">CCriticalSection</a> at its constructor, and releasing it at destructor. </p> <p>It is a better idea to always use <a class="el" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html" title="A class acquiring a CCriticalSection at its constructor, and releasing it at destructor.">CCriticalSectionLocker</a>, since it is more secure in the case of possible exceptions, many different exit points from a function, etc.. : it will always release the critical section at the destructor. Example: </p> <div class="fragment"><pre class="fragment"> { <span class="comment">// Code in this scope is protected by critical section</span> <a class="code" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html#add36490c5e8df02cc4345adcc2a694a2" title="Constructor: enters the critical section.">CCriticalSectionLocker</a> myCSLocker( &myCS ); ... } <span class="comment">// End of code protected by critical section</span> </pre></div> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classmrpt_1_1synch_1_1_c_critical_section.html" title="This class provides simple critical sections functionality.">CCriticalSection</a>, <a class="el" href="_c_critical_section_8h.html#a063b848901ed4201c26e195505d31faf" title="A macro for protecting a given piece of code with a critical section; for example:">THREADSAFE_OPERATION</a> </dd></dl> </div> <p><code>#include <<a class="el" href="_c_critical_section_8h_source.html">mrpt/synch/CCriticalSection.h</a>></code></p> <p><a href="classmrpt_1_1synch_1_1_c_critical_section_locker-members.html">List of all members.</a></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html#add36490c5e8df02cc4345adcc2a694a2">CCriticalSectionLocker</a> (const <a class="el" href="classmrpt_1_1synch_1_1_c_critical_section.html">CCriticalSection</a> *<a class="el" href="cs_8h.html#a44e471a015cf32e012cffef17e81b6db">cs</a>)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor: enters the critical section. <a href="#add36490c5e8df02cc4345adcc2a694a2"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html#a40fb663d5f936a9567cb21f7873649a2">CCriticalSectionLocker</a> (const <a class="el" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html">CCriticalSectionLocker</a> &o)</td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html">CCriticalSectionLocker</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html#a4d6a89a6f9b32af6fc268bb69edbff51">operator=</a> (const <a class="el" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html">CCriticalSectionLocker</a> &o)</td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html#a3d8bee9aa6c614d236639671023f2b4d">~CCriticalSectionLocker</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Destructor: leaves the critical section. <a href="#a3d8bee9aa6c614d236639671023f2b4d"></a><br/></td></tr> <tr><td colspan="2"><h2><a name="pro-attribs"></a> Protected Attributes</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">const <a class="el" href="classmrpt_1_1synch_1_1_c_critical_section.html">CCriticalSection</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html#a69f2166082c3b2876d314994e29449c5">m_cs</a></td></tr> </table> <hr/><h2>Constructor & Destructor Documentation</h2> <a class="anchor" id="add36490c5e8df02cc4345adcc2a694a2"></a><!-- doxytag: member="mrpt::synch::CCriticalSectionLocker::CCriticalSectionLocker" ref="add36490c5e8df02cc4345adcc2a694a2" args="(const CCriticalSection *cs)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">mrpt::synch::CCriticalSectionLocker::CCriticalSectionLocker </td> <td>(</td> <td class="paramtype">const <a class="el" href="classmrpt_1_1synch_1_1_c_critical_section.html">CCriticalSection</a> * </td> <td class="paramname"><em>cs</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Constructor: enters the critical section. </p> </div> </div> <a class="anchor" id="a40fb663d5f936a9567cb21f7873649a2"></a><!-- doxytag: member="mrpt::synch::CCriticalSectionLocker::CCriticalSectionLocker" ref="a40fb663d5f936a9567cb21f7873649a2" args="(const CCriticalSectionLocker &o)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">mrpt::synch::CCriticalSectionLocker::CCriticalSectionLocker </td> <td>(</td> <td class="paramtype">const <a class="el" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html">CCriticalSectionLocker</a> & </td> <td class="paramname"><em>o</em></td><td>)</td> <td><code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="_c_critical_section_8h_source.html#l00106">106</a> of file <a class="el" href="_c_critical_section_8h_source.html">CCriticalSection.h</a>.</p> </div> </div> <a class="anchor" id="a3d8bee9aa6c614d236639671023f2b4d"></a><!-- doxytag: member="mrpt::synch::CCriticalSectionLocker::~CCriticalSectionLocker" ref="a3d8bee9aa6c614d236639671023f2b4d" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">mrpt::synch::CCriticalSectionLocker::~CCriticalSectionLocker </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Destructor: leaves the critical section. </p> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="a4d6a89a6f9b32af6fc268bb69edbff51"></a><!-- doxytag: member="mrpt::synch::CCriticalSectionLocker::operator=" ref="a4d6a89a6f9b32af6fc268bb69edbff51" args="(const CCriticalSectionLocker &o)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html">CCriticalSectionLocker</a>& mrpt::synch::CCriticalSectionLocker::operator= </td> <td>(</td> <td class="paramtype">const <a class="el" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html">CCriticalSectionLocker</a> & </td> <td class="paramname"><em>o</em></td><td>)</td> <td><code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="_c_critical_section_8h_source.html#l00110">110</a> of file <a class="el" href="_c_critical_section_8h_source.html">CCriticalSection.h</a>.</p> <p>References <a class="el" href="_c_critical_section_8h_source.html#l00099">m_cs</a>.</p> </div> </div> <hr/><h2>Member Data Documentation</h2> <a class="anchor" id="a69f2166082c3b2876d314994e29449c5"></a><!-- doxytag: member="mrpt::synch::CCriticalSectionLocker::m_cs" ref="a69f2166082c3b2876d314994e29449c5" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const <a class="el" href="classmrpt_1_1synch_1_1_c_critical_section.html">CCriticalSection</a>* <a class="el" href="classmrpt_1_1synch_1_1_c_critical_section_locker.html#a69f2166082c3b2876d314994e29449c5">mrpt::synch::CCriticalSectionLocker::m_cs</a><code> [protected]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="_c_critical_section_8h_source.html#l00099">99</a> of file <a class="el" href="_c_critical_section_8h_source.html">CCriticalSection.h</a>.</p> <p>Referenced by <a class="el" href="_c_critical_section_8h_source.html#l00110">operator=()</a>.</p> </div> </div> </div> <br><hr><br> <table border="0" width="100%"> <tr> <td> Page generated by <a href="http://www.doxygen.org" target="_blank">Doxygen 1.7.5</a> for MRPT 0.9.5 SVN: at Sun Sep 25 17:20:18 UTC 2011</td><td></td> <td width="100"> </td> <td width="150"> </td></tr> </table> </body></html>