<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.yar-concurrent-client.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'tr',
  ),
  'this' => 
  array (
    0 => 'yar-concurrent-client.loop.php',
    1 => 'Yar_Concurrent_Client::loop',
    2 => 'Send and wait for all registered calls',
  ),
  'up' => 
  array (
    0 => 'class.yar-concurrent-client.php',
    1 => 'Yar_Concurrent_Client',
  ),
  'prev' => 
  array (
    0 => 'yar-concurrent-client.call.php',
    1 => 'Yar_Concurrent_Client::call',
  ),
  'next' => 
  array (
    0 => 'yar-concurrent-client.reset.php',
    1 => 'Yar_Concurrent_Client::reset',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yar/yar_concurrent_client/loop.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="yar-concurrent-client.loop" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yar_Concurrent_Client::loop</h1>
  <p class="verinfo">(PECL yar &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Yar_Concurrent_Client::loop</span> &mdash; <span class="dc-title">Send and wait for all registered calls</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yar-concurrent-client.loop-description">
  <h3 class="title">Açıklama</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="modifier">function</span> <span class="methodname"><strong>Yar_Concurrent_Client::loop</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span></span> <code class="parameter">$callback</code><span class="initializer"> = null</span></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span></span> <code class="parameter">$error_callback</code><span class="initializer"> = null</span></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.array.php" class="type array">array</a></span></span> <code class="parameter">$options</code><span class="initializer"> = null</span></span>): <span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></span></div>

  <p class="simpara">
   Sends all calls registered with
   <span class="methodname"><a href="yar-concurrent-client.call.php" class="methodname">Yar_Concurrent_Client::call()</a></span> in parallel and
   blocks until every response has arrived and been handled. The call list
   is emptied when this method returns.
  </p>
  <p class="simpara">
   Because the calls run simultaneously, the loop takes only as long as
   the slowest single call rather than the sum of all calls. The
   callbacks, however, are not invoked in the order the calls were
   registered: a callback fires as soon as its response arrives. To find
   out which call a response belongs to, check the
   <code class="literal">sequence</code> entry of the <code class="literal">callinfo</code>
   argument against the sequence number returned by
   <span class="methodname"><a href="yar-concurrent-client.call.php" class="methodname">Yar_Concurrent_Client::call()</a></span>. The
   <code class="literal">callinfo</code> <span class="type"><a href="language.types.array.php" class="type array">array</a></span> holds the
   <code class="literal">sequence</code>, <code class="literal">uri</code> and
   <code class="literal">method</code> of the call; see
   <span class="methodname"><a href="yar-concurrent-client.call.php" class="methodname">Yar_Concurrent_Client::call()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yar-concurrent-client.loop-parameters">
  <h3 class="title">Bağımsız Değişkenler</h3>
  <dl>
   
    <dt><code class="parameter">callback</code></dt>
    <dd>
     <p class="simpara">
      A <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> used to handle responses for calls that were
      registered without their own callback. Right after all requests have
      been sent, it is additionally called once with two <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> arguments,
      before any response arrives.
     </p>
     <p class="simpara">
      If this parameter is omitted, the return value of a successful call
      is simply printed when its response arrives.
     </p>
    </dd>
   
   
    <dt><code class="parameter">error_callback</code></dt>
    <dd>
     <p class="simpara">
      A <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> used to handle errors for calls that were
      registered without their own error callback. It receives three
      arguments: the error type (one of the <code class="literal">YAR_ERR_*</code>
      codes), the error message, and the <code class="literal">callinfo</code>
      <span class="type"><a href="language.types.array.php" class="type array">array</a></span>.
     </p>
     <p class="simpara">
      If this parameter is omitted, a failed call raises a PHP warning
      instead; unlike the synchronous
      <span class="classname"><a href="class.yar-client.php" class="classname">Yar_Client</a></span>, no exception is thrown.
     </p>
    </dd>
   
   
    <dt><code class="parameter">options</code></dt>
    <dd>
     <p class="simpara">
      An <span class="type"><a href="language.types.array.php" class="type array">array</a></span> of client options, keyed by the
      <code class="literal">YAR_OPT_*</code> constants, applied to every registered
      call that does not override them.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-yar-concurrent-client.loop-returnvalues">
  <h3 class="title">Dönen Değerler</h3>
  <p class="simpara">
   Returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> when every registered call has been handled, or when no
   calls have been registered at all. Returns <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if the concurrent
   client is already running inside another loop; in that case a warning is
   raised.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-yar-concurrent-client.loop-examples">
  <h3 class="title">Örnekler</h3>
  <div class="example" id="example-1">
   <p><strong>Örnek 1 <span class="methodname"><strong>Yar_Concurrent_Client::loop()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php
</span><span style="color: #007700">function </span><span style="color: #0000BB">callback</span><span style="color: #007700">(</span><span style="color: #0000BB">$retval</span><span style="color: #007700">, </span><span style="color: #0000BB">$callinfo</span><span style="color: #007700">) {
    if (</span><span style="color: #0000BB">$callinfo </span><span style="color: #007700">== </span><span style="color: #0000BB">NULL</span><span style="color: #007700">) {
        echo </span><span style="color: #DD0000">"Now, all requests are sent, and no response available\n"</span><span style="color: #007700">;
    } else {
        echo </span><span style="color: #DD0000">"This is a remote call response, the method name is "</span><span style="color: #007700">, </span><span style="color: #0000BB">$callinfo</span><span style="color: #007700">[</span><span style="color: #DD0000">"method"</span><span style="color: #007700">],
             </span><span style="color: #DD0000">". calling sequence is "</span><span style="color: #007700">, </span><span style="color: #0000BB">$callinfo</span><span style="color: #007700">[</span><span style="color: #DD0000">"sequence"</span><span style="color: #007700">], </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;
        </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$retval</span><span style="color: #007700">);
    }
}

function </span><span style="color: #0000BB">error_callback</span><span style="color: #007700">(</span><span style="color: #0000BB">$type</span><span style="color: #007700">, </span><span style="color: #0000BB">$error</span><span style="color: #007700">, </span><span style="color: #0000BB">$callinfo</span><span style="color: #007700">) {
    </span><span style="color: #0000BB">error_log</span><span style="color: #007700">(</span><span style="color: #0000BB">$error</span><span style="color: #007700">);
}

</span><span style="color: #0000BB">Yar_Concurrent_Client</span><span style="color: #007700">::</span><span style="color: #0000BB">call</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://api.example.com/operator.php"</span><span style="color: #007700">, </span><span style="color: #DD0000">"some_method"</span><span style="color: #007700">, array(</span><span style="color: #DD0000">"parameters"</span><span style="color: #007700">), </span><span style="color: #DD0000">"callback"</span><span style="color: #007700">);

</span><span style="color: #FF8000">/* if the callback is not specified, the callback of loop() will be used */
</span><span style="color: #0000BB">Yar_Concurrent_Client</span><span style="color: #007700">::</span><span style="color: #0000BB">call</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://api.example.com/operator.php"</span><span style="color: #007700">, </span><span style="color: #DD0000">"some_method"</span><span style="color: #007700">, array(</span><span style="color: #DD0000">"parameters"</span><span style="color: #007700">));

</span><span style="color: #0000BB">Yar_Concurrent_Client</span><span style="color: #007700">::</span><span style="color: #0000BB">loop</span><span style="color: #007700">(</span><span style="color: #DD0000">"callback"</span><span style="color: #007700">, </span><span style="color: #DD0000">"error_callback"</span><span style="color: #007700">);
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

   <div class="example-contents"><p>
Yukarıdaki örnek şuna benzer bir çıktı üretir:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Now, all requests are sent, and no response available
This is a remote call response, the method name is some_method. calling sequence is 2
string(11) &quot;some_method&quot;
This is a remote call response, the method name is some_method. calling sequence is 1
string(11) &quot;some_method&quot;</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-yar-concurrent-client.loop-seealso">
  <h3 class="title">Ayrıca Bakınız</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="yar-concurrent-client.call.php" class="methodname" rel="rdfs-seeAlso">Yar_Concurrent_Client::call()</a> - Register a concurrent call</span></li>
   <li><span class="methodname"><a href="yar-concurrent-client.reset.php" class="methodname" rel="rdfs-seeAlso">Yar_Concurrent_Client::reset()</a> - Clean all registered calls</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>