uTools-Manuals/docs/php/eio_poll.html
2019-04-28 19:00:34 +08:00

82 lines
4.9 KiB
HTML

<!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>Can be to be called whenever there are pending requests that need finishing</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.eio-poll" class="refentry">
<div class="refnamediv">
<h1 class="refname">eio_poll</h1>
<p class="verinfo">(PECL eio &gt;= 0.0.1dev)</p><p class="refpurpose"><span class="refname">eio_poll</span> &mdash; <span class="dc-title">Can be to be called whenever there are pending requests that need finishing</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.eio-poll-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>eio_poll</strong></span>
( <span class="methodparam">void</span>
) : <span class="type">int</span></div>
<p class="para rdfs-comment">
<span class="function"><strong>eio_poll()</strong></span> can be used to implement special event loop.
For this <span class="function"><a href="eio_nreqs.html" class="function">eio_nreqs()</a></span> could be used to test if there are
unprocessed requests.
</p>
<blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">Applicable only when implementing userspace event loop.</p></p></blockquote>
</div>
<div class="refsect1 parameters" id="refsect1-function.eio-poll-parameters">
<h3 class="title">参数</h3>
<p class="para">此函数没有参数。</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.eio-poll-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
If any request invocation returns a non-zero value, returns that value.
Otherwise, it returns <strong><code>0</code></strong>.
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.eio-poll-examples">
<h3 class="title">范例</h3>
<div class="example" id="example-4282">
<p><strong>Example #1 <span class="function"><strong>eio_poll()</strong></span> example</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">res_cb</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">eio_nop</span><span style="color: #007700">(</span><span style="color: #0000BB">EIO_PRI_DEFAULT</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"res_cb"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"1"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">eio_nop</span><span style="color: #007700">(</span><span style="color: #0000BB">EIO_PRI_DEFAULT</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"res_cb"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"2"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">eio_nop</span><span style="color: #007700">(</span><span style="color: #0000BB">EIO_PRI_DEFAULT</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"res_cb"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"3"</span><span style="color: #007700">);<br /><br />while&nbsp;(</span><span style="color: #0000BB">eio_nreqs</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Some&nbsp;specific&nbsp;IPC&nbsp;or&nbsp;so<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">eio_poll</span><span style="color: #007700">();<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
<div class="example-contents"><p>以上例程的输出类似于:</p></div>
<div class="example-contents screen">
<div class="cdata"><pre>
string(1) &quot;1&quot;
int(0)
string(1) &quot;3&quot;
int(0)
string(1) &quot;2&quot;
int(0)
</pre></div>
</div>
</div>
</div>
<div class="refsect1 seealso" id="refsect1-function.eio-poll-seealso">
<h3 class="title">参见</h3>
<ul class="simplelist">
<li class="member">eio_nreqs</li>
</ul>
</div>
</div></div></div></body></html>