mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Change: sync with svn changes
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@318754 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
f1c03cc865
commit
043fadeac3
4 changed files with 23 additions and 47 deletions
|
@ -105,14 +105,11 @@ eio_event_loop();
|
|||
request that opens, reads and closes a file.
|
||||
</para>
|
||||
<para>
|
||||
Since version 0.3.0 alpha, a file descriptor used for communications with
|
||||
libeio internally, could be retrieved with
|
||||
<function>eio_get_eventfd</function>. The file descriptor could be used to
|
||||
bind to an event loop supported by some other extension. For instance,
|
||||
<emphasis>libevent</emphasis> currently(Fri Oct 28 01:07:55 UZT 2011)
|
||||
supports numeric file descriptors in both basic and buffered APIs in SVN.
|
||||
Thus, you might organize a simple event loop where eio and libevent work
|
||||
together:
|
||||
Since version 0.3.0 alpha, a variable used in communications with libeio
|
||||
internally, could be retrieved with
|
||||
<function>eio_get_event_stream</function>. The variable could be used
|
||||
to bind to an event loop supported by some other extension. You might
|
||||
organize a simple event loop where eio and libevent work together:
|
||||
<example>
|
||||
<title>Using eio with libevent</title>
|
||||
<programlisting role="php"><![CDATA[
|
||||
|
@ -132,8 +129,8 @@ function my_res_cb($d, $r) {
|
|||
$base = event_base_new();
|
||||
$event = event_new();
|
||||
|
||||
// Get eio's file descriptor
|
||||
$fd = eio_get_eventfd();
|
||||
// This stream is used to bind with libevent
|
||||
$fd = eio_get_event_stream();
|
||||
|
||||
eio_nop(EIO_PRI_DEFAULT, "my_res_cb", "nop data");
|
||||
eio_mkdir("/tmp/abc-eio-temp", 0750, EIO_PRI_DEFAULT, "my_res_cb", "mkdir data");
|
||||
|
@ -143,16 +140,9 @@ eio_mkdir("/tmp/abc-eio-temp", 0750, EIO_PRI_DEFAULT, "my_res_cb", "mkdir data")
|
|||
// set event flags
|
||||
event_set($event, $fd, EV_READ /*| EV_PERSIST*/, "my_eio_poll", array($event, $base));
|
||||
|
||||
// Set event priorities
|
||||
event_base_priority_init($base, 10);
|
||||
|
||||
// set event base
|
||||
event_base_set($event, $base);
|
||||
|
||||
// This one is currently in SVN, but should appear in the next libevent
|
||||
// release
|
||||
event_priority_set($event, 2);
|
||||
|
||||
// enable event
|
||||
event_add($event);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ my_nop 2
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$temp_filename = "eio-temp-file.tmp";
|
||||
$temp_filename = dirname(__FILE__) ."/eio-temp-file.tmp";
|
||||
touch($temp_filename);
|
||||
|
||||
/* Is called when eio_chmod() finished */
|
||||
|
@ -208,8 +208,7 @@ function my_nop_cb($d, $r) {
|
|||
$base = event_base_new();
|
||||
$event = event_new();
|
||||
|
||||
// Get eio's file descriptor
|
||||
$fd = eio_get_eventfd();
|
||||
$fd = eio_get_event_stream();
|
||||
var_dump($fd);
|
||||
|
||||
eio_nop(EIO_PRI_DEFAULT, "my_nop_cb", "nop data");
|
||||
|
@ -220,16 +219,9 @@ eio_mkdir("/tmp/abc-eio-temp", 0750, EIO_PRI_DEFAULT, "my_nop_cb", "nop data");
|
|||
// set event flags
|
||||
event_set($event, $fd, EV_READ /*| EV_PERSIST*/, "my_eio_poll", array($event, $base));
|
||||
|
||||
// Set event priorities
|
||||
event_base_priority_init($base, 10);
|
||||
|
||||
// set event base
|
||||
event_base_set($event, $base);
|
||||
|
||||
// This one is currently in SVN, but should appear in the next libevent
|
||||
// release
|
||||
event_priority_set($event, 2);
|
||||
|
||||
// enable event
|
||||
event_add($event);
|
||||
|
||||
|
|
|
@ -3,20 +3,21 @@
|
|||
|
||||
<refentry xml:id="function.eio-get-eventfd" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>eio_get_eventfd</refname>
|
||||
<refpurpose>Get the file descriptor used in internal communications with libeio.</refpurpose>
|
||||
<refname>eio_get_event_stream</refname>
|
||||
<refpurpose>Get stream representing a variable used in internal communications with libeio.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>int</type><methodname>eio_get_eventfd</methodname>
|
||||
<type>mixed</type><methodname>eio_get_event_stream</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
<function>eio_get_eventfd</function> acquires the file descriptor used in
|
||||
internal communications with libeio. Could be used to bind with some event
|
||||
loop provided by other PECL extension, for example libevent.
|
||||
<function>eio_get_event_stream</function> acquires stream representing a
|
||||
variable used in internal communications with libeio. Could be used to bind
|
||||
with some event loop provided by other PECL extension, for example
|
||||
libevent.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
|
@ -28,7 +29,8 @@
|
|||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
<function>eio_get_eventfd</function> returns the numeric file desriptor.
|
||||
<function>eio_get_event_stream</function> returns stream on success;
|
||||
otherwise, &null;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
|
@ -47,35 +49,27 @@ function my_eio_poll($fd, $events, $arg) {
|
|||
/* .. and here */
|
||||
}
|
||||
|
||||
function my_nop_cb($d, $r) {
|
||||
function my_res_cb($d, $r) {
|
||||
var_dump($r); var_dump($d);
|
||||
}
|
||||
|
||||
$base = event_base_new();
|
||||
$event = event_new();
|
||||
|
||||
// Get eio's file descriptor
|
||||
$fd = eio_get_eventfd();
|
||||
$fd = eio_get_event_stream();
|
||||
var_dump($fd);
|
||||
|
||||
eio_nop(EIO_PRI_DEFAULT, "my_nop_cb", "nop data");
|
||||
eio_mkdir("/tmp/abc-eio-temp", 0750, EIO_PRI_DEFAULT, "my_nop_cb", "nop data");
|
||||
eio_nop(EIO_PRI_DEFAULT, "my_res_cb", "nop data");
|
||||
eio_mkdir("/tmp/abc-eio-temp", 0750, EIO_PRI_DEFAULT, "my_res_cb", "mkdir data");
|
||||
/* some other eio_* calls here ... */
|
||||
|
||||
|
||||
// set event flags
|
||||
event_set($event, $fd, EV_READ /*| EV_PERSIST*/, "my_eio_poll", array($event, $base));
|
||||
|
||||
// Set event priorities
|
||||
event_base_priority_init($base, 10);
|
||||
|
||||
// set event base
|
||||
event_base_set($event, $base);
|
||||
|
||||
// This one is currently in SVN, but should appear in the next libevent
|
||||
// release
|
||||
event_priority_set($event, 2);
|
||||
|
||||
// enable event
|
||||
event_add($event);
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
<function name='eio_busy' from='PECL eio >= 0.0.1dev'/>
|
||||
<function name='eio_nop' from='PECL eio >= 0.0.1dev'/>
|
||||
<function name='eio_cancel' from='PECL eio >= 0.0.1dev'/>
|
||||
<function name='eio_get_eventfd' from='PECL eio >= 0.3.0a'/>
|
||||
<function name='eio_get_event_stream' from='PECL eio >= 0.3.1b'/>
|
||||
<function name='eio_grp' from='PECL eio >= 0.0.1dev'/>
|
||||
<function name='eio_grp_add' from='PECL eio >= 0.0.1dev'/>
|
||||
<function name='eio_grp_cancel' from='PECL eio >= 0.0.1dev'/>
|
||||
|
|
Loading…
Reference in a new issue