1
0
mirror of https://github.com/danog/amp.git synced 2024-11-27 04:24:42 +01:00
amp/test
Daniel Lowrey 094899a74b Add boolean "keep_alive" option for all watcher types
This option determines if the watcher will keep the run() loop
from returning. By default all watchers set "keep_alive" => true.
Setting this value to false is ideal for registering non-crucial
watchers (e.g. cache invalidation timers) that should run for the
life of the program but shouldn't prevent the event loop from
returning if all essential tasks have completed.

    <?php
    echo "before run\n";
    run(function () {
        immediately(function () {
            echo "immediately\n";
        });
        once(function () {
            echo "once\n";
        }, 100, ["keep_alive" => false]);
        repeat(function () {
            echo "repeat\n";
        }, 500, ["keep_alive" => false]);
        echo "onStart end\n";
    });
    echo "after run\n";

The above snippet will have the following output:

before run
immediately
after run

The Amp\info() function now also reports the number of
keep_alive watchers currently registered via the "keep_alive" key.
2015-07-31 09:32:22 -04:00
..
bootstrap.php misc v1 cleanup 2015-07-29 23:23:53 -04:00
EvReactorTest.php Add boolean "keep_alive" option for all watcher types 2015-07-31 09:32:22 -04:00
FailureTest.php misc updates and tests 2015-07-20 22:27:11 -04:00
FunctionsTest.php Move to procedural API 2015-07-29 16:59:53 -04:00
LibeventReactorTest.php Move to procedural API 2015-07-29 16:59:53 -04:00
NativeReactorTest.php Move to procedural API 2015-07-29 16:59:53 -04:00
PauseTest.php Move to procedural API 2015-07-29 16:59:53 -04:00
PlaceholderPrivateTest.php Expose boolean AMP_DEBUG for performance tuning 2015-05-18 23:57:34 -04:00
PlaceholderPublicTest.php Expose boolean AMP_DEBUG for performance tuning 2015-05-18 23:57:34 -04:00
PlaceholderTest.php misc updates + tests 2015-07-21 12:25:34 -04:00
PromisorPrivateTest.php Pass optional data parameter to when/watch callbacks 2015-05-19 18:49:38 -04:00
PromisorPublicTest.php misc updates + tests 2015-07-21 12:25:34 -04:00
PromisorTest.php Move to procedural API 2015-07-29 16:59:53 -04:00
ReactorTest.php Add boolean "keep_alive" option for all watcher types 2015-07-31 09:32:22 -04:00
StructTest.php misc v1 cleanup 2015-07-29 23:23:53 -04:00
SuccessTest.php misc updates and tests 2015-07-20 22:27:11 -04:00
UvReactorTest.php Add boolean "keep_alive" option for all watcher types 2015-07-31 09:32:22 -04:00