<trclass="memitem:a1128f81a47324e6de3946a7719c24223"id="r_a1128f81a47324e6de3946a7719c24223"><tdclass="memItemLeft"align="right"valign="top">bool </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="classUSemaphore.html#a1128f81a47324e6de3946a7719c24223">acquire</a> (int n=1, int ms=0)</td></tr>
<p>On an <aclass="el"href="classUSemaphore.html#a1128f81a47324e6de3946a7719c24223">acquire()</a> call, the calling thread is blocked if the <aclass="el"href="classUSemaphore.html">USemaphore</a>'s value is <= 0. It is unblocked when <aclass="el"href="classUSemaphore.html#a693b35a08fd5363b14f3a220081814b5">release()</a> is called. The function <aclass="el"href="classUSemaphore.html#a1128f81a47324e6de3946a7719c24223">acquire()</a> decreases by 1 (default) the semaphore's value and <aclass="el"href="classUSemaphore.html#a693b35a08fd5363b14f3a220081814b5">release()</a> increases it by 1 (default).</p>
<divclass="line">s.<aclass="code hl_function"href="classUSemaphore.html#a1128f81a47324e6de3946a7719c24223">acquire</a>(); <spanclass="comment">// Will wait until s.release() is called by another thread.</span></div>
<divclass="ttc"id="aclassUSemaphore_html_a1128f81a47324e6de3946a7719c24223"><divclass="ttname"><ahref="classUSemaphore.html#a1128f81a47324e6de3946a7719c24223">USemaphore::acquire</a></div><divclass="ttdeci">bool acquire(int n=1, int ms=0)</div><divclass="ttdef"><b>Definition</b><ahref="USemaphore_8h_source.html#l00108">USemaphore.h:108</a></div></div>
</div><!-- fragment --><dlclass="section see"><dt>See also</dt><dd><aclass="el"href="classUMutex.html">UMutex</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="USemaphore_8h_source.html#l00055">55</a> of file <aclass="el"href="USemaphore_8h_source.html">USemaphore.h</a>.</p>
</div><h2class="groupheader">Constructor & Destructor Documentation</h2>
<p>The constructor. The semaphore waits on <aclass="el"href="classUSemaphore.html#a1128f81a47324e6de3946a7719c24223">acquire()</a> when its value is <= 0. </p><dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">n</td><td>number to initialize </td></tr>
</table>
</dd>
</dl>
<pclass="definition">Definition at line <aclass="el"href="USemaphore_8h_source.html#l00062">62</a> of file <aclass="el"href="USemaphore_8h_source.html">USemaphore.h</a>.</p>
<pclass="definition">Definition at line <aclass="el"href="USemaphore_8h_source.html#l00076">76</a> of file <aclass="el"href="USemaphore_8h_source.html">USemaphore.h</a>.</p>
</div>
</div>
<h2class="groupheader">Member Function Documentation</h2>
<p>Acquire the semaphore. If semaphore's value is <=0, the calling thread will wait until the count acquired is released. </p><dlclass="section see"><dt>See also</dt><dd><aclass="el"href="classUSemaphore.html#a693b35a08fd5363b14f3a220081814b5">release()</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">n</td><td>number to acquire </td></tr>
<tr><tdclass="paramname">t</td><td>time to wait (ms), a value <=0 means infinite </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>true on success, false on error/timeout </dd></dl>
<pclass="definition">Definition at line <aclass="el"href="USemaphore_8h_source.html#l00108">108</a> of file <aclass="el"href="USemaphore_8h_source.html">USemaphore.h</a>.</p>
<tr><tdclass="paramname">n</td><td>the number to acquire. </td></tr>
</table>
</dd>
</dl>
<pclass="definition">Definition at line <aclass="el"href="USemaphore_8h_source.html#l00164">164</a> of file <aclass="el"href="USemaphore_8h_source.html">USemaphore.h</a>.</p>
<p>Release the semaphore, increasing its value by n and signaling waiting threads (which called <aclass="el"href="classUSemaphore.html#a1128f81a47324e6de3946a7719c24223">acquire()</a>). </p><dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">n</td><td>the number to release. </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>0 on success, ERANGE if the release would push the semaphore over SEM_VALUE_MAX (the count is then left unchanged). The Unix implementation cannot fail and always returns 0. </dd></dl>
<pclass="definition">Definition at line <aclass="el"href="USemaphore_8h_source.html#l00197">197</a> of file <aclass="el"href="USemaphore_8h_source.html">USemaphore.h</a>.</p>
<p>Get the USempahore's value. </p><dlclass="section return"><dt>Returns</dt><dd>the semaphore's value </dd></dl>
<pclass="definition">Definition at line <aclass="el"href="USemaphore_8h_source.html#l00221">221</a> of file <aclass="el"href="USemaphore_8h_source.html">USemaphore.h</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<liclass="footer">Generated by <ahref="https://www.doxygen.org/index.html"><imgclass="footer"src="doxygen.svg"width="104"height="31"alt="doxygen"/></a> 1.9.8 </li>