From 93fa84169d21f24256266312ea0cf3a9362d99ae Mon Sep 17 00:00:00 2001 From: Ruslan Osmanov Date: Thu, 27 Dec 2012 14:48:05 +0000 Subject: [PATCH] Fix: tabs git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@328907 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/ev/ev/embeddablebackends.xml | 8 +- reference/ev/ev/recommendedbackends.xml | 8 +- reference/ev/ev/supportedbackends.xml | 8 +- reference/ev/evembed/construct.xml | 8 +- reference/ev/evperiodic/construct.xml | 9 +- reference/ev/evsignal/construct.xml | 5 +- reference/ev/evstat/attr.xml | 20 +-- reference/ev/evstat/construct.xml | 20 +-- reference/ev/evtimer/construct.xml | 20 +-- reference/ev/evtimer/createstopped.xml | 12 +- reference/ev/examples.xml | 166 ++++++++++++------------ reference/ev/watchers.xml | 2 +- 12 files changed, 143 insertions(+), 143 deletions(-) diff --git a/reference/ev/ev/embeddablebackends.xml b/reference/ev/ev/embeddablebackends.xml index 86fcdf1817..eee620bd36 100644 --- a/reference/ev/ev/embeddablebackends.xml +++ b/reference/ev/ev/embeddablebackends.xml @@ -53,13 +53,13 @@ $socket_loop = NULL; $embed = NULL; if (Ev::supportedBackends() & ~Ev::recommendedBackends() & Ev::BACKEND_KQUEUE) { - if (($socket_loop = new EvLoop(Ev::BACKEND_KQUEUE))) { - $embed = new EvEmbed($loop); - } + if (($socket_loop = new EvLoop(Ev::BACKEND_KQUEUE))) { + $embed = new EvEmbed($loop); + } } if (!$socket_loop) { - $socket_loop = $loop; + $socket_loop = $loop; } // Now use $socket_loop for all sockets, and $loop for anything else diff --git a/reference/ev/ev/recommendedbackends.xml b/reference/ev/ev/recommendedbackends.xml index a2e4a12cfb..48565f8715 100644 --- a/reference/ev/ev/recommendedbackends.xml +++ b/reference/ev/ev/recommendedbackends.xml @@ -66,13 +66,13 @@ $embed = NULL; * (flags' value of 0 means autodetection) */ $loop_lo = Ev::embeddableBackends() & Ev::recommendedBackends() - ? new EvLoop(Ev::embeddableBackends() & Ev::recommendedBackends()) - : 0; + ? new EvLoop(Ev::embeddableBackends() & Ev::recommendedBackends()) + : 0; if ($loop_lo) { - $embed = new EvEmbed($loop_lo, function () {}); + $embed = new EvEmbed($loop_lo, function () {}); } else { - $loop_lo = $loop_hi; + $loop_lo = $loop_hi; } ?> ]]> diff --git a/reference/ev/ev/supportedbackends.xml b/reference/ev/ev/supportedbackends.xml index 770411adf7..0fdaddf00a 100644 --- a/reference/ev/ev/supportedbackends.xml +++ b/reference/ev/ev/supportedbackends.xml @@ -55,13 +55,13 @@ $socket_loop = NULL; $embed = NULL; if (Ev::supportedBackends() & ~Ev::recommendedBackends() & Ev::BACKEND_KQUEUE) { - if (($socket_loop = new EvLoop(Ev::BACKEND_KQUEUE))) { - $embed = new EvEmbed($loop); - } + if (($socket_loop = new EvLoop(Ev::BACKEND_KQUEUE))) { + $embed = new EvEmbed($loop); + } } if (!$socket_loop) { - $socket_loop = $loop; + $socket_loop = $loop; } // Now use $socket_loop for all sockets, and $loop for anything else diff --git a/reference/ev/evembed/construct.xml b/reference/ev/evembed/construct.xml index e944ae8eb8..55dff36062 100644 --- a/reference/ev/evembed/construct.xml +++ b/reference/ev/evembed/construct.xml @@ -101,13 +101,13 @@ $socket_loop = NULL; $embed = NULL; if (Ev::supportedBackends() & ~Ev::recommendedBackends() & Ev::BACKEND_KQUEUE) { - if (($socket_loop = new EvLoop(Ev::BACKEND_KQUEUE))) { - $embed = new EvEmbed($loop); - } + if (($socket_loop = new EvLoop(Ev::BACKEND_KQUEUE))) { + $embed = new EvEmbed($loop); + } } if (!$socket_loop) { - $socket_loop = $loop; + $socket_loop = $loop; } // Now use $socket_loop for all sockets, and $loop for anything else diff --git a/reference/ev/evperiodic/construct.xml b/reference/ev/evperiodic/construct.xml index ecddf29b55..36f47ab1a8 100644 --- a/reference/ev/evperiodic/construct.xml +++ b/reference/ev/evperiodic/construct.xml @@ -102,12 +102,11 @@ // Tick each 10.5 seconds function reschedule_cb ($watcher, $now) { - return $now + (10.5. - fmod($now, 10.5)); - + return $now + (10.5. - fmod($now, 10.5)); } $w = new EvPeriodic(0., 0., "reschedule_cb", function ($w, $revents) { - echo time(), PHP_EOL; + echo time(), PHP_EOL; }); Ev::run(); ?> @@ -123,7 +122,7 @@ Ev::run(); @@ -137,7 +136,7 @@ Ev::run(); ]]> diff --git a/reference/ev/evsignal/construct.xml b/reference/ev/evsignal/construct.xml index 58148b0558..04508f9cc0 100644 --- a/reference/ev/evsignal/construct.xml +++ b/reference/ev/evsignal/construct.xml @@ -79,9 +79,10 @@ stop(); + echo "SIGTERM received\n"; + $watcher->stop(); }); + Ev::run(); ?> ]]> diff --git a/reference/ev/evstat/attr.xml b/reference/ev/evstat/attr.xml index 182f02a8f5..6a2040ecda 100644 --- a/reference/ev/evstat/attr.xml +++ b/reference/ev/evstat/attr.xml @@ -111,18 +111,18 @@ attr(); + $attr = $w->attr(); - if ($attr['nlink']) { - printf("Current size: %ld\n", $attr['size']); - printf("Current atime: %ld\n", $attr['atime']); - printf("Current mtime: %ld\n", $attr['mtime']); - } else { - fprintf(STDERR, "`messages` file is not there!"); - $w->stop(); - } + if ($attr['nlink']) { + printf("Current size: %ld\n", $attr['size']); + printf("Current atime: %ld\n", $attr['atime']); + printf("Current mtime: %ld\n", $attr['mtime']); + } else { + fprintf(STDERR, "`messages` file is not there!"); + $w->stop(); + } }); Ev::run(); diff --git a/reference/ev/evstat/construct.xml b/reference/ev/evstat/construct.xml index 9d509fb8fb..dc3ded32f2 100644 --- a/reference/ev/evstat/construct.xml +++ b/reference/ev/evstat/construct.xml @@ -90,18 +90,18 @@ attr(); + $attr = $w->attr(); - if ($attr['nlink']) { - printf("Current size: %ld\n", $attr['size']); - printf("Current atime: %ld\n", $attr['atime']); - printf("Current mtime: %ld\n", $attr['mtime']); - } else { - fprintf(STDERR, "`messages` file is not there!"); - $w->stop(); - } + if ($attr['nlink']) { + printf("Current size: %ld\n", $attr['size']); + printf("Current atime: %ld\n", $attr['atime']); + printf("Current mtime: %ld\n", $attr['mtime']); + } else { + fprintf(STDERR, "`messages` file is not there!"); + $w->stop(); + } }); Ev::run(); diff --git a/reference/ev/evtimer/construct.xml b/reference/ev/evtimer/construct.xml index c24dbff102..8d3e01ac4f 100644 --- a/reference/ev/evtimer/construct.xml +++ b/reference/ev/evtimer/construct.xml @@ -90,27 +90,27 @@ stop(); - // Stop the watcher if further calls cause more than 10 iterations - Ev::iteration() >= 10 and $w->stop(); + // Stop the watcher after 5 iterations + Ev::iteration() == 5 and $w->stop(); + // Stop the watcher if further calls cause more than 10 iterations + Ev::iteration() >= 10 and $w->stop(); }); // Create stopped timer. It will be inactive until we start it ourselves $w_stopped = EvTimer::createStopped(10, 5, function($w) { - echo "Callback of a timer created as stopped\n"; + echo "Callback of a timer created as stopped\n"; - // Stop the watcher after 2 iterations - Ev::iteration() >= 2 and $w->stop(); + // Stop the watcher after 2 iterations + Ev::iteration() >= 2 and $w->stop(); }); // Loop until Ev::stop() is called or all of watchers stop diff --git a/reference/ev/evtimer/createstopped.xml b/reference/ev/evtimer/createstopped.xml index 7affce2e28..7a9e01c0cf 100644 --- a/reference/ev/evtimer/createstopped.xml +++ b/reference/ev/evtimer/createstopped.xml @@ -93,17 +93,17 @@ stop(); + $w->stop(); - $stat = $w->data; + $stat = $w->data; - // 1 second after the most recent change of the file - printf("Current size: %ld\n", $stat->attr()['size']); + // 1 second after the most recent change of the file + printf("Current size: %ld\n", $stat->attr()['size']); }); $stat = new EvStat("/var/log/messages", 0., function () use ($timer) { - // Reset timer watcher - $timer->again(); + // Reset timer watcher + $timer->again(); }); $timer->data = $stat; diff --git a/reference/ev/examples.xml b/reference/ev/examples.xml index 6a8988f436..cd06b15c65 100644 --- a/reference/ev/examples.xml +++ b/reference/ev/examples.xml @@ -10,27 +10,27 @@ stop(); - // Stop the watcher if further calls cause more than 10 iterations - Ev::iteration() >= 10 and $w->stop(); + // Stop the watcher after 5 iterations + Ev::iteration() == 5 and $w->stop(); + // Stop the watcher if further calls cause more than 10 iterations + Ev::iteration() >= 10 and $w->stop(); }); // Create stopped timer. It will be inactive until we start it ourselves $w_stopped = EvTimer::createStopped(10, 5, function($w) { - echo "Callback of a timer created as stopped\n"; + echo "Callback of a timer created as stopped\n"; - // Stop the watcher after 2 iterations - Ev::iteration() >= 2 and $w->stop(); + // Stop the watcher after 2 iterations + Ev::iteration() >= 2 and $w->stop(); }); // Loop until Ev::stop() is called or all of watchers stop @@ -87,7 +87,7 @@ END @@ -124,7 +124,7 @@ Ev::run(); @@ -139,7 +139,7 @@ Ev::run(); @@ -170,7 +170,7 @@ $address = gethostbyname('google.co.uk'); $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket === FALSE) { echo "socket_create() failed: reason: " - .socket_strerror(socket_last_error()) . "\n"; + .socket_strerror(socket_last_error()) . "\n"; } // Set O_NONBLOCK flag @@ -178,50 +178,50 @@ socket_set_nonblock($socket); // Abort on timeout $timeout_watcher = new EvTimer(10.0, 0., function () use ($socket) { - socket_close($socket); - Ev::stop(Ev::BREAK_ALL); + socket_close($socket); + Ev::stop(Ev::BREAK_ALL); }); // Make HEAD request when the socket is writable $write_watcher = new EvIo($socket, Ev::WRITE, function ($w) - use ($socket, $timeout_watcher, $e_nonblocking) { - // Stop timeout watcher - $timeout_watcher->stop(); - // Stop write watcher - $w->stop(); + use ($socket, $timeout_watcher, $e_nonblocking) { + // Stop timeout watcher + $timeout_watcher->stop(); + // Stop write watcher + $w->stop(); - $in = "HEAD / HTTP/1.1\r\n"; - $in .= "Host: google.co.uk\r\n"; - $in .= "Connection: Close\r\n\r\n"; + $in = "HEAD / HTTP/1.1\r\n"; + $in .= "Host: google.co.uk\r\n"; + $in .= "Connection: Close\r\n\r\n"; - if (!socket_write($socket, $in, strlen($in))) { - trigger_error("Failed writing $in to socket", E_USER_ERROR); - } + if (!socket_write($socket, $in, strlen($in))) { + trigger_error("Failed writing $in to socket", E_USER_ERROR); + } - $read_watcher = new EvIo($socket, Ev::READ, function ($w, $re) - use ($socket, $e_nonblocking) { - // Socket is readable. recv() 20 bytes using non-blocking mode - $ret = socket_recv($socket, $out, 20, MSG_DONTWAIT); + $read_watcher = new EvIo($socket, Ev::READ, function ($w, $re) + use ($socket, $e_nonblocking) { + // Socket is readable. recv() 20 bytes using non-blocking mode + $ret = socket_recv($socket, $out, 20, MSG_DONTWAIT); - if ($ret) { - echo $out; - } elseif ($ret === 0) { - // All read - $w->stop(); - socket_close($socket); - return; - } + if ($ret) { + echo $out; + } elseif ($ret === 0) { + // All read + $w->stop(); + socket_close($socket); + return; + } - // Caught EINPROGRESS, EAGAIN, or EWOULDBLOCK - if (in_array(socket_last_error(), $e_nonblocking)) { - return; - } + // Caught EINPROGRESS, EAGAIN, or EWOULDBLOCK + if (in_array(socket_last_error(), $e_nonblocking)) { + return; + } - $w->stop(); - socket_close($socket); - }); + $w->stop(); + socket_close($socket); + }); - Ev::run(); + Ev::run(); }); $result = socket_connect($socket, $address, $service_port); @@ -274,13 +274,13 @@ $embed = NULL; * (flags' value of 0 means autodetection) */ $loop_lo = Ev::embeddableBackends() & Ev::recommendedBackends() - ? new EvLoop(Ev::embeddableBackends() & Ev::recommendedBackends()) - : 0; + ? new EvLoop(Ev::embeddableBackends() & Ev::recommendedBackends()) + : 0; if ($loop_lo) { - $embed = new EvEmbed($loop_lo, function () {}); + $embed = new EvEmbed($loop_lo, function () {}); } else { - $loop_lo = $loop_hi; + $loop_lo = $loop_hi; } ?> ]]> @@ -306,13 +306,13 @@ $socket_loop = NULL; $embed = NULL; if (Ev::supportedBackends() & ~Ev::recommendedBackends() & Ev::BACKEND_KQUEUE) { - if (($socket_loop = new EvLoop(Ev::BACKEND_KQUEUE))) { - $embed = new EvEmbed($loop); - } + if (($socket_loop = new EvLoop(Ev::BACKEND_KQUEUE))) { + $embed = new EvEmbed($loop); + } } if (!$socket_loop) { - $socket_loop = $loop; + $socket_loop = $loop; } // Now use $socket_loop for all sockets, and $loop for anything else @@ -327,8 +327,8 @@ if (!$socket_loop) { stop(); + echo "SIGTERM received\n"; + $watcher->stop(); }); Ev::run(); ?> @@ -343,18 +343,18 @@ Ev::run(); attr(); + $attr = $w->attr(); - if ($attr['nlink']) { - printf("Current size: %ld\n", $attr['size']); - printf("Current atime: %ld\n", $attr['atime']); - printf("Current mtime: %ld\n", $attr['mtime']); - } else { - fprintf(STDERR, "`messages` file is not there!"); - $w->stop(); - } + if ($attr['nlink']) { + printf("Current size: %ld\n", $attr['size']); + printf("Current atime: %ld\n", $attr['atime']); + printf("Current mtime: %ld\n", $attr['mtime']); + } else { + fprintf(STDERR, "`messages` file is not there!"); + $w->stop(); + } }); Ev::run(); @@ -369,17 +369,17 @@ Ev::run(); stop(); + $w->stop(); - $stat = $w->data; + $stat = $w->data; - // 1 second after the most recent change of the file - printf("Current size: %ld\n", $stat->attr()['size']); + // 1 second after the most recent change of the file + printf("Current size: %ld\n", $stat->attr()['size']); }); $stat = new EvStat("/var/log/messages", 0., function () use ($timer) { - // Reset timer watcher - $timer->again(); + // Reset timer watcher + $timer->again(); }); $timer->data = $stat; @@ -398,21 +398,21 @@ Ev::run(); $pid = pcntl_fork(); if ($pid == -1) { - fprintf(STDERR, "pcntl_fork failed\n"); + fprintf(STDERR, "pcntl_fork failed\n"); } elseif ($pid) { - $w = new EvChild($pid, FALSE, function ($w, $revents) { - $w->stop(); + $w = new EvChild($pid, FALSE, function ($w, $revents) { + $w->stop(); - printf("Process %d exited with status %d\n", $w->rpid, $w->rstatus); - }); + printf("Process %d exited with status %d\n", $w->rpid, $w->rstatus); + }); - Ev::run(); + Ev::run(); - // Protect against Zombies - pcntl_wait($status); + // Protect against Zombies + pcntl_wait($status); } else { - //Forked child - exit(2); + //Forked child + exit(2); } ?> ]]> diff --git a/reference/ev/watchers.xml b/reference/ev/watchers.xml index def1ab488a..03f30c9320 100644 --- a/reference/ev/watchers.xml +++ b/reference/ev/watchers.xml @@ -12,7 +12,7 @@