mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Applied PHP source formatting within programlisting tags
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@328911 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
8d666e8198
commit
9ec46b8b8a
5 changed files with 40 additions and 40 deletions
|
@ -113,26 +113,26 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Check if kqueue is available but not recommended and create a kqueue backend
|
||||
* for use with sockets (which usually work with any kqueue implementation).
|
||||
* Store the kqueue/socket-only event loop in loop_socket. (One might optionally
|
||||
* use EVFLAG_NOENV, too)
|
||||
*
|
||||
* Example borrowed from
|
||||
* http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#Examples_CONTENT-9
|
||||
*/
|
||||
* Check if kqueue is available but not recommended and create a kqueue backend
|
||||
* for use with sockets (which usually work with any kqueue implementation).
|
||||
* Store the kqueue/socket-only event loop in loop_socket. (One might optionally
|
||||
* use EVFLAG_NOENV, too)
|
||||
*
|
||||
* Example borrowed from
|
||||
* http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#Examples_CONTENT-9
|
||||
*/
|
||||
$loop = EvLoop::defaultLoop();
|
||||
$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
|
||||
|
|
|
@ -103,8 +103,8 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
$w = new EvSignal(SIGTERM, function ($watcher) {
|
||||
echo "SIGTERM received\n";
|
||||
$watcher->stop();
|
||||
echo "SIGTERM received\n";
|
||||
$watcher->stop();
|
||||
});
|
||||
|
||||
Ev::run();
|
||||
|
|
|
@ -136,18 +136,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();
|
||||
|
|
|
@ -117,27 +117,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
|
||||
|
|
|
@ -121,17 +121,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;
|
||||
|
|
Loading…
Reference in a new issue