<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Yate: Mutex Class Reference</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.7.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</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> </ul> </div> <div class="tabs"> <ul> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="namespaceTelEngine.html">TelEngine</a>::<a class="el" href="classTelEngine_1_1Mutex.html">Mutex</a> </div> </div> <div class="contents"> <h1>Mutex Class Reference</h1><!-- doxytag: class="TelEngine::Mutex" --><a class="el" href="classTelEngine_1_1Mutex.html" title="Mutex support.">Mutex</a> support. <a href="#_details">More...</a> <p> <code>#include <<a class="el" href="yateclass_8h-source.html">yateclass.h</a>></code> <p> <div class="dynheader"> Inheritance diagram for Mutex:</div> <div class="dynsection"> <p><center><img src="classTelEngine_1_1Mutex.png" usemap="#Mutex_map" border="0" alt=""></center> <map name="Mutex_map"> <area href="classTelEngine_1_1AnalogLine.html" alt="AnalogLine" shape="rect" coords="149,56,288,80"> <area href="classTelEngine_1_1ClientAccount.html" alt="ClientAccount" shape="rect" coords="149,112,288,136"> <area href="classTelEngine_1_1ClientAccountList.html" alt="ClientAccountList" shape="rect" coords="149,168,288,192"> <area href="classTelEngine_1_1IAXEngine.html" alt="IAXEngine" shape="rect" coords="149,224,288,248"> <area href="classTelEngine_1_1IAXMetaTrunkFrame.html" alt="IAXMetaTrunkFrame" shape="rect" coords="149,280,288,304"> <area href="classTelEngine_1_1IAXTransaction.html" alt="IAXTransaction" shape="rect" coords="149,336,288,360"> <area href="classTelEngine_1_1JBEngine.html" alt="JBEngine" shape="rect" coords="149,392,288,416"> <area href="classTelEngine_1_1JBService.html" alt="JBService" shape="rect" coords="149,448,288,472"> <area href="classTelEngine_1_1JGSession.html" alt="JGSession" shape="rect" coords="149,504,288,528"> <area href="classTelEngine_1_1JIDResourceList.html" alt="JIDResourceList" shape="rect" coords="149,560,288,584"> <area href="classTelEngine_1_1MGCPEngine.html" alt="MGCPEngine" shape="rect" coords="149,616,288,640"> <area href="classTelEngine_1_1MGCPTransaction.html" alt="MGCPTransaction" shape="rect" coords="149,672,288,696"> <area href="classTelEngine_1_1Module.html" alt="Module" shape="rect" coords="149,728,288,752"> <area href="classTelEngine_1_1RTPGroup.html" alt="RTPGroup" shape="rect" coords="149,784,288,808"> <area href="classTelEngine_1_1SignallingCallControl.html" alt="SignallingCallControl" shape="rect" coords="149,840,288,864"> <area href="classTelEngine_1_1SignallingCircuitGroup.html" alt="SignallingCircuitGroup" shape="rect" coords="149,896,288,920"> <area href="classTelEngine_1_1SignallingEngine.html" alt="SignallingEngine" shape="rect" coords="149,952,288,976"> <area href="classTelEngine_1_1SS7MTP2.html" alt="SS7MTP2" shape="rect" coords="149,1008,288,1032"> <area href="classTelEngine_1_1SS7MTP3.html" alt="SS7MTP3" shape="rect" coords="149,1064,288,1088"> <area href="classTelEngine_1_1SS7Router.html" alt="SS7Router" shape="rect" coords="149,1120,288,1144"> <area href="classTelEngine_1_1XMLParser.html" alt="XMLParser" shape="rect" coords="149,1176,288,1200"> <area href="classTelEngine_1_1XMPPUser.html" alt="XMPPUser" shape="rect" coords="149,1232,288,1256"> <area href="classTelEngine_1_1XMPPUserRoster.html" alt="XMPPUserRoster" shape="rect" coords="149,1288,288,1312"> </map> </div> <p> <a href="classTelEngine_1_1Mutex-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0"> <tr><td></td></tr> <tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classTelEngine_1_1Mutex.html#4b5dfbd24f5bc4c03b24b2da362f66d5">Mutex</a> ()</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classTelEngine_1_1Mutex.html#6eec79393ac7768a4e30da45630ad45f">Mutex</a> (bool recursive)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classTelEngine_1_1Mutex.html#8560fe2746a2ebd6df832630c2c5c050">Mutex</a> (const <a class="el" href="classTelEngine_1_1Mutex.html">Mutex</a> &original)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classTelEngine_1_1Mutex.html#205e2c334b25cb96e4f1303a4fde6b0c">~Mutex</a> ()</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="classTelEngine_1_1Mutex.html">Mutex</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classTelEngine_1_1Mutex.html#969bbcac21e72e63b136898600e0eb54">operator=</a> (const <a class="el" href="classTelEngine_1_1Mutex.html">Mutex</a> &original)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTelEngine_1_1Mutex.html#85e4f242cf8d817e30b68bfacf375713">lock</a> (long maxwait=-1)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTelEngine_1_1Mutex.html#9278be8203e1c42e2619179882ae4403">unlock</a> ()</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTelEngine_1_1Mutex.html#278ee3d69582e50938dd6a879098bb4b">locked</a> () const </td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTelEngine_1_1Mutex.html#a924b088a55dbdddff007e03af108224">check</a> (long maxwait=-1)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTelEngine_1_1Mutex.html#d8b86113498de28297d9769091198bd6">recursive</a> () const </td></tr> <tr><td colspan="2"><br><h2>Static Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">static int </td><td class="memItemRight" valign="bottom"><a class="el" href="classTelEngine_1_1Mutex.html#09624f463911151150731cf8f9cb485d">count</a> ()</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">static int </td><td class="memItemRight" valign="bottom"><a class="el" href="classTelEngine_1_1Mutex.html#bf9eea2b9068820f945485dd07fd75f2">locks</a> ()</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTelEngine_1_1Mutex.html#acf24ce1269b1b113931e198a1b60ca9">wait</a> (unsigned long maxwait)</td></tr> <tr><td colspan="2"><br><h2>Friends</h2></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="9aab3f30d662ddd199b34b546957e465"></a><!-- doxytag: member="TelEngine::Mutex::MutexPrivate" ref="9aab3f30d662ddd199b34b546957e465" args="" --> class </td><td class="memItemRight" valign="bottom"><b>MutexPrivate</b></td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> <a class="el" href="classTelEngine_1_1Mutex.html" title="Mutex support.">Mutex</a> support. <p> A simple mutual exclusion for locking access between threads <hr><h2>Constructor & Destructor Documentation</h2> <a class="anchor" name="4b5dfbd24f5bc4c03b24b2da362f66d5"></a><!-- doxytag: member="TelEngine::Mutex::Mutex" ref="4b5dfbd24f5bc4c03b24b2da362f66d5" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classTelEngine_1_1Mutex.html">Mutex</a> </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p> Construct a new unlocked fast mutex </div> </div><p> <a class="anchor" name="6eec79393ac7768a4e30da45630ad45f"></a><!-- doxytag: member="TelEngine::Mutex::Mutex" ref="6eec79393ac7768a4e30da45630ad45f" args="(bool recursive)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classTelEngine_1_1Mutex.html">Mutex</a> </td> <td>(</td> <td class="paramtype">bool </td> <td class="paramname"> <em>recursive</em> </td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p> Construct a new unlocked mutex <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>recursive</em> </td><td>True if the mutex has to be recursive (reentrant), false for a normal fast mutex </td></tr> </table> </dl> </div> </div><p> <a class="anchor" name="8560fe2746a2ebd6df832630c2c5c050"></a><!-- doxytag: member="TelEngine::Mutex::Mutex" ref="8560fe2746a2ebd6df832630c2c5c050" args="(const Mutex &original)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classTelEngine_1_1Mutex.html">Mutex</a> </td> <td>(</td> <td class="paramtype">const <a class="el" href="classTelEngine_1_1Mutex.html">Mutex</a> & </td> <td class="paramname"> <em>original</em> </td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p> Copy constructor creates a shared mutex <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>original</em> </td><td>Reference of the mutex to share </td></tr> </table> </dl> </div> </div><p> <a class="anchor" name="205e2c334b25cb96e4f1303a4fde6b0c"></a><!-- doxytag: member="TelEngine::Mutex::~Mutex" ref="205e2c334b25cb96e4f1303a4fde6b0c" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">~<a class="el" href="classTelEngine_1_1Mutex.html">Mutex</a> </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p> Destroy the mutex </div> </div><p> <hr><h2>Member Function Documentation</h2> <a class="anchor" name="a924b088a55dbdddff007e03af108224"></a><!-- doxytag: member="TelEngine::Mutex::check" ref="a924b088a55dbdddff007e03af108224" args="(long maxwait=-1)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool check </td> <td>(</td> <td class="paramtype">long </td> <td class="paramname"> <em>maxwait</em> = <code>-1</code> </td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p> Check if the mutex is unlocked (try to lock and unlock the mutex) <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>maxwait</em> </td><td><a class="el" href="classTelEngine_1_1Time.html" title="A time holding class.">Time</a> in microseconds to wait for the mutex, -1 wait forever </td></tr> </table> </dl> <dl class="return" compact><dt><b>Returns:</b></dt><dd>True if successfully locked and unlocked, false on failure </dd></dl> </div> </div><p> <a class="anchor" name="09624f463911151150731cf8f9cb485d"></a><!-- doxytag: member="TelEngine::Mutex::count" ref="09624f463911151150731cf8f9cb485d" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static int count </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Get the number of mutexes counting the shared ones only once <dl class="return" compact><dt><b>Returns:</b></dt><dd>Count of individual mutexes </dd></dl> </div> </div><p> <a class="anchor" name="85e4f242cf8d817e30b68bfacf375713"></a><!-- doxytag: member="TelEngine::Mutex::lock" ref="85e4f242cf8d817e30b68bfacf375713" args="(long maxwait=-1)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool lock </td> <td>(</td> <td class="paramtype">long </td> <td class="paramname"> <em>maxwait</em> = <code>-1</code> </td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p> Attempt to lock the mutex and eventually wait for it <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>maxwait</em> </td><td><a class="el" href="classTelEngine_1_1Time.html" title="A time holding class.">Time</a> in microseconds to wait for the mutex, -1 wait forever </td></tr> </table> </dl> <dl class="return" compact><dt><b>Returns:</b></dt><dd>True if successfully locked, false on failure </dd></dl> <p>Referenced by <a class="el" href="yateclass_8h-source.html#l03394">Lock::Lock()</a>.</p> </div> </div><p> <a class="anchor" name="278ee3d69582e50938dd6a879098bb4b"></a><!-- doxytag: member="TelEngine::Mutex::locked" ref="278ee3d69582e50938dd6a879098bb4b" args="() const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool locked </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p> Check if the mutex is currently locked - as it's asynchronous it guarantees nothing if other thread changes the mutex's status <dl class="return" compact><dt><b>Returns:</b></dt><dd>True if the mutex was locked when the function was called </dd></dl> </div> </div><p> <a class="anchor" name="bf9eea2b9068820f945485dd07fd75f2"></a><!-- doxytag: member="TelEngine::Mutex::locks" ref="bf9eea2b9068820f945485dd07fd75f2" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static int locks </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Get the number of currently locked mutexes <dl class="return" compact><dt><b>Returns:</b></dt><dd>Count of locked mutexes, should be zero at program exit </dd></dl> </div> </div><p> <a class="anchor" name="969bbcac21e72e63b136898600e0eb54"></a><!-- doxytag: member="TelEngine::Mutex::operator=" ref="969bbcac21e72e63b136898600e0eb54" args="(const Mutex &original)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classTelEngine_1_1Mutex.html">Mutex</a>& operator= </td> <td>(</td> <td class="paramtype">const <a class="el" href="classTelEngine_1_1Mutex.html">Mutex</a> & </td> <td class="paramname"> <em>original</em> </td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p> Assignment operator makes the mutex shared with the original <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>original</em> </td><td>Reference of the mutex to share </td></tr> </table> </dl> </div> </div><p> <a class="anchor" name="d8b86113498de28297d9769091198bd6"></a><!-- doxytag: member="TelEngine::Mutex::recursive" ref="d8b86113498de28297d9769091198bd6" args="() const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool recursive </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p> Check if this mutex is recursive or not <dl class="return" compact><dt><b>Returns:</b></dt><dd>True if this is a recursive mutex, false for a fast mutex </dd></dl> </div> </div><p> <a class="anchor" name="9278be8203e1c42e2619179882ae4403"></a><!-- doxytag: member="TelEngine::Mutex::unlock" ref="9278be8203e1c42e2619179882ae4403" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void unlock </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p> Unlock the mutex, does never wait <p>Referenced by <a class="el" href="yateclass_8h-source.html#l03408">Lock::~Lock()</a>.</p> </div> </div><p> <a class="anchor" name="acf24ce1269b1b113931e198a1b60ca9"></a><!-- doxytag: member="TelEngine::Mutex::wait" ref="acf24ce1269b1b113931e198a1b60ca9" args="(unsigned long maxwait)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static void wait </td> <td>(</td> <td class="paramtype">unsigned long </td> <td class="paramname"> <em>maxwait</em> </td> <td> ) </td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Set a maximum mutex wait time for debugging purposes <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>maxwait</em> </td><td>Maximum time in microseconds to wait for any mutex when no time limit was requested, zero to disable limit </td></tr> </table> </dl> </div> </div><p> <hr>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="yateclass_8h-source.html">yateclass.h</a></ul> </div> <hr size="1"><address style="text-align: right;"><small>Generated on Sun Dec 7 21:36:11 2008 for Yate by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.7.1 </small></address> </body> </html>