mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Fix: tabs
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@328907 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
a2eb5f627e
commit
93fa84169d
12 changed files with 143 additions and 143 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
|||
<?php
|
||||
// Tick every 10.5 seconds starting at now
|
||||
$w = new EvPeriodic(fmod(Ev::now(), 10.5), 10.5, NULL, function ($w, $revents) {
|
||||
echo time(), PHP_EOL;
|
||||
echo time(), PHP_EOL;
|
||||
});
|
||||
Ev::run();
|
||||
?>
|
||||
|
@ -137,7 +136,7 @@ Ev::run();
|
|||
<![CDATA[
|
||||
<?php
|
||||
$hourly = EvPeriodic(0, 3600, NULL, function () {
|
||||
echo "once per hour\n";
|
||||
echo "once per hour\n";
|
||||
};
|
||||
?>
|
||||
]]>
|
||||
|
|
|
@ -79,9 +79,10 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
$w = new EvSignal(SIGTERM, function ($watcher) {
|
||||
echo "SIGTERM received\n";
|
||||
$watcher->stop();
|
||||
echo "SIGTERM received\n";
|
||||
$watcher->stop();
|
||||
});
|
||||
|
||||
Ev::run();
|
||||
?>
|
||||
]]>
|
||||
|
|
|
@ -111,18 +111,18 @@
|
|||
<?php
|
||||
// Use 10 second update interval.
|
||||
$w = new EvStat("/var/log/messages", 8, function ($w) {
|
||||
echo "/var/log/messages changed\n";
|
||||
echo "/var/log/messages changed\n";
|
||||
|
||||
$attr = $w->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();
|
||||
|
|
|
@ -90,18 +90,18 @@
|
|||
<?php
|
||||
// Use 10 second update interval.
|
||||
$w = new EvStat("/var/log/messages", 8, function ($w) {
|
||||
echo "/var/log/messages changed\n";
|
||||
echo "/var/log/messages changed\n";
|
||||
|
||||
$attr = $w->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();
|
||||
|
|
|
@ -90,27 +90,27 @@
|
|||
<?php
|
||||
// Create and start timer firing after 2 seconds
|
||||
$w1 = new EvTimer(2, 0, function () {
|
||||
echo "2 seconds elapsed\n";
|
||||
echo "2 seconds elapsed\n";
|
||||
});
|
||||
|
||||
// Create and launch timer firing after 2 seconds repeating each second
|
||||
// until we manually stop it
|
||||
$w2 = new EvTimer(2, 1, function ($w) {
|
||||
echo "is called every second, is launched after 2 seconds\n";
|
||||
echo "iteration = ", Ev::iteration(), PHP_EOL;
|
||||
echo "is called every second, is launched after 2 seconds\n";
|
||||
echo "iteration = ", Ev::iteration(), PHP_EOL;
|
||||
|
||||
// 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();
|
||||
// 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
|
||||
|
|
|
@ -93,17 +93,17 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
$timer = EvTimer::createStopped(0., 1.02, function ($w) {
|
||||
$w->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;
|
||||
|
|
|
@ -10,27 +10,27 @@
|
|||
<?php
|
||||
// Create and start timer firing after 2 seconds
|
||||
$w1 = new EvTimer(2, 0, function () {
|
||||
echo "2 seconds elapsed\n";
|
||||
echo "2 seconds elapsed\n";
|
||||
});
|
||||
|
||||
// Create and launch timer firing after 2 seconds repeating each second
|
||||
// until we manually stop it
|
||||
$w2 = new EvTimer(2, 1, function ($w) {
|
||||
echo "is called every second, is launched after 2 seconds\n";
|
||||
echo "iteration = ", Ev::iteration(), PHP_EOL;
|
||||
echo "is called every second, is launched after 2 seconds\n";
|
||||
echo "iteration = ", Ev::iteration(), PHP_EOL;
|
||||
|
||||
// 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();
|
||||
// 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
|
|||
<![CDATA[
|
||||
<?php
|
||||
$w = new EvPeriodic(0., 10.5, NULL, function ($w, $revents) {
|
||||
echo time(), PHP_EOL;
|
||||
echo time(), PHP_EOL;
|
||||
});
|
||||
Ev::run();
|
||||
?>
|
||||
|
@ -124,7 +124,7 @@ Ev::run();
|
|||
<?php
|
||||
// Tick every 10.5 seconds starting at now
|
||||
$w = new EvPeriodic(fmod(Ev::now(), 10.5), 10.5, NULL, function ($w, $revents) {
|
||||
echo time(), PHP_EOL;
|
||||
echo time(), PHP_EOL;
|
||||
});
|
||||
Ev::run();
|
||||
?>
|
||||
|
@ -139,7 +139,7 @@ Ev::run();
|
|||
<?php
|
||||
// Wait until STDIN is readable
|
||||
$w = new EvIo(STDIN, Ev::READ, function ($watcher, $revents) {
|
||||
echo "STDIN is readable\n";
|
||||
echo "STDIN is readable\n";
|
||||
});
|
||||
Ev::run(Ev::RUN_ONCE);
|
||||
?>
|
||||
|
@ -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) {
|
|||
<![CDATA[
|
||||
<?php
|
||||
$w = new EvSignal(SIGTERM, function ($watcher) {
|
||||
echo "SIGTERM received\n";
|
||||
$watcher->stop();
|
||||
echo "SIGTERM received\n";
|
||||
$watcher->stop();
|
||||
});
|
||||
Ev::run();
|
||||
?>
|
||||
|
@ -343,18 +343,18 @@ Ev::run();
|
|||
<?php
|
||||
// Use 10 second update interval.
|
||||
$w = new EvStat("/var/log/messages", 8, function ($w) {
|
||||
echo "/var/log/messages changed\n";
|
||||
echo "/var/log/messages changed\n";
|
||||
|
||||
$attr = $w->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();
|
|||
<![CDATA[
|
||||
<?php
|
||||
$timer = EvTimer::createStopped(0., 1.02, function ($w) {
|
||||
$w->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);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<?php
|
||||
// Wait until STDIN is readable
|
||||
$w = new EvIo(STDIN, Ev::READ, function ($watcher, $revents) {
|
||||
echo "STDIN is readable\n";
|
||||
echo "STDIN is readable\n";
|
||||
});
|
||||
Ev::run(Ev::RUN_ONCE);
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue