Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 13816

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Constructs a new SyncSemaphore object</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.syncsemaphore.html">SyncSemaphore</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="syncsemaphore.lock.html">SyncSemaphore::lock</a></div>
 <div class="up"><a href="class.syncsemaphore.html">SyncSemaphore</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="syncsemaphore.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SyncSemaphore::__construct</h1>
  <p class="verinfo">(PECL sync &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">SyncSemaphore::__construct</span> &mdash; <span class="dc-title">Constructs a new SyncSemaphore object</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-syncsemaphore.construct-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SyncSemaphore::__construct</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$initialval</code><span class="initializer"> = 1</span></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$autounlock</code><span class="initializer"> = <strong><code>TRUE</code></strong></span></span>
  ]]] )</div>

  <p class="para rdfs-comment">
 Constructs a named or unnamed semaphore.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-syncsemaphore.construct-parameters">
  <h3 class="title">Parameters</h3>
  <dl>

   
    <dt>
<code class="parameter">name</code></dt>

    <dd>

     <p class="para">
 The name of the semaphore if this is a named semaphore object.
     </p>
     <blockquote class="note"><p><strong class="note">Note</strong>: 
      <p class="para">
 If the name already exists, it must be able to be opened by the current user
 that the process is running as or an exception will be thrown with a meaningless
 error message.
      </p>
     </p></blockquote>
    </dd>

   
   
    <dt>
<code class="parameter">initialval</code></dt>

    <dd>

     <p class="para">
 The initial value of the semaphore.  This is the number of locks that may be obtained.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">autounlock</code></dt>

    <dd>

     <p class="para">
 Specifies whether or not to automatically unlock the semaphore at the
 conclusion of the PHP script.
     </p>
     <div class="warning"><strong class="warning">Warning</strong>
      <p class="para">
 If an object is:  A named semaphore with an autounlock of FALSE, the object is
 locked, and the PHP script concludes before the object is unlocked, then the
 underlying semaphore will end up in an inconsistent state.
      </p>
     </div>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-syncsemaphore.construct-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
 The new SyncSemaphore object.  An exception is thrown if the semaphore cannot
 be created or opened.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-syncsemaphore.construct-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-4594">
   <p><strong>Example #1 <span class="function"><strong>SyncSemaphore::__construct()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$semaphore&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SyncSemaphore</span><span style="color: #007700">(</span><span style="color: #DD0000">"LimitedResource_2clients"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br /><br />if&nbsp;(!</span><span style="color: #0000BB">$semaphore</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">lock</span><span style="color: #007700">(</span><span style="color: #0000BB">3000</span><span style="color: #007700">))<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Unable&nbsp;to&nbsp;lock&nbsp;semaphore."</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;exit();<br />}<br /><br /></span><span style="color: #FF8000">/*&nbsp;...&nbsp;*/<br /><br /></span><span style="color: #0000BB">$semaphore</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">unlock</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-syncsemaphore.construct-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li class="member"><span class="methodname"><a href="syncsemaphore.lock.html" class="methodname" rel="rdfs-seeAlso">SyncSemaphore::lock()</a> - Decreases the count of the semaphore or waits</span></li>
   <li class="member"><span class="methodname"><a href="syncsemaphore.unlock.html" class="methodname" rel="rdfs-seeAlso">SyncSemaphore::unlock()</a> - Increases the count of the semaphore</span></li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.syncsemaphore.html">SyncSemaphore</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="syncsemaphore.lock.html">SyncSemaphore::lock</a></div>
 <div class="up"><a href="class.syncsemaphore.html">SyncSemaphore</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>