1
0
mirror of https://github.com/danog/amp.git synced 2024-11-27 04:24:42 +01:00
amp/lib
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
..
CoroutineResult.php misc v1 cleanup 2015-07-29 23:23:53 -04:00
CoroutineState.php misc v1 cleanup 2015-07-29 23:23:53 -04:00
Deferred.php update coverage ignore 2015-07-22 13:12:14 -04:00
EvReactor.php Add boolean "keep_alive" option for all watcher types 2015-07-31 09:32:22 -04:00
Failure.php promise updates are no longer variadic + misc formatting 2015-07-27 10:08:02 -04:00
functions.php Add boolean "keep_alive" option for all watcher types 2015-07-31 09:32:22 -04:00
LibeventReactor.php Add boolean "keep_alive" option for all watcher types 2015-07-31 09:32:22 -04:00
NativeReactor.php Add boolean "keep_alive" option for all watcher types 2015-07-31 09:32:22 -04:00
Pause.php misc v1 cleanup 2015-07-29 23:23:53 -04:00
Placeholder.php promise updates are no longer variadic + misc formatting 2015-07-27 10:08:02 -04:00
PrivatePlaceholder.php promise updates are no longer variadic + misc formatting 2015-07-27 10:08:02 -04:00
PrivatePromisor.php promise updates are no longer variadic + misc formatting 2015-07-27 10:08:02 -04:00
Promise.php promise updates are no longer variadic + misc formatting 2015-07-27 10:08:02 -04:00
Promisor.php Replace BaseException refs with Throwable 2015-07-07 10:15:57 -04:00
PublicPromisor.php misc updates + tests 2015-07-21 12:25:34 -04:00
Reactor.php Add boolean "keep_alive" option for all watcher types 2015-07-31 09:32:22 -04:00
Struct.php Suggest nearby property name in Struct error messages 2015-05-13 10:05:56 -04:00
Success.php promise updates are no longer variadic + misc formatting 2015-07-27 10:08:02 -04:00
UvReactor.php Add boolean "keep_alive" option for all watcher types 2015-07-31 09:32:22 -04:00
Watcher.php misc v1 cleanup 2015-07-29 23:23:53 -04:00