1
0
mirror of https://github.com/danog/amp.git synced 2024-12-04 02:17:54 +01:00
Commit Graph

84 Commits

Author SHA1 Message Date
Niklas Keller
00898cd6af Convert RuntimeException to CombinatorException 2015-09-23 22:56:55 +02:00
Niklas Keller
2fe4c65faa Catch Throwables in __coroutineSend on PHP 7 2015-08-18 08:55:44 +02:00
Daniel Lowrey
861fca1ebd Fix outdated docblocks 2015-08-16 20:33:07 -04:00
Daniel Lowrey
5cad406795 Normalize coroutine() return to Promise type 2015-08-07 11:01:36 -04:00
Daniel Lowrey
70f4971ae1 Remove stream() in favor of PromiseStream 2015-08-04 23:46:49 -04:00
Daniel Lowrey
f840ee4334 update incorrect docblock 2015-08-01 23:03:25 -04:00
Daniel Lowrey
2c8727133e functor argument is now optional in Amp\filter()
If no functor parameter is supplied, all results equal to FALSE
using a (bool) cast will be removed.
2015-08-01 13:28:41 -04:00
Daniel Lowrey
705c57483b Fail promise timeout() operations using TimeoutException 2015-07-31 15:50:27 -04:00
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
Daniel Lowrey
bdd8503cbe init() -> driver() 2015-07-31 09:32:21 -04:00
Daniel Lowrey
8bcbba41a0 Move to procedural API 2015-07-29 16:59:53 -04:00
Daniel Lowrey
1d9d572ee5 promise updates are no longer variadic + misc formatting 2015-07-27 10:08:02 -04:00
Daniel Lowrey
38b3fbbbbb move PromiseStream functionality into Amp\stream() 2015-07-23 15:23:45 -04:00
Daniel Lowrey
55e379e332 Rollback static coroutine methods to namespaced functions 2015-07-23 01:30:53 -04:00
Daniel Lowrey
a4636851d6 remove deprecated functions 2015-07-22 14:49:40 -04:00
Daniel Lowrey
505c59d0e3 minor cleanup 2015-07-22 12:34:42 -04:00
Daniel Lowrey
2cea028b1c filter() updates and tests 2015-07-21 20:09:27 -04:00
Daniel Lowrey
33fd20acb3 add tests 2015-07-21 17:25:18 -04:00
Daniel Lowrey
d6b674b93b Move coroutine functions into new Coroutine class 2015-07-21 16:14:50 -04:00
Daniel Lowrey
564a81c519 misc updates + tests 2015-07-21 12:25:34 -04:00
Daniel Lowrey
288530d296 Add EvReactor 2015-07-20 15:42:42 -04:00
Daniel Lowrey
ad96a584d5 Check coroutine nesting level before incurring "next tick" overhead 2015-06-16 12:08:24 -04:00
Daniel Lowrey
c7d0f3f86e error traceback improvement 2015-06-16 11:10:53 -04:00
Daniel Lowrey
40fbb6e16d Minor coroutine refactoring/optimization; add makeGeneratorError() 2015-06-16 10:59:44 -04:00
Daniel Lowrey
1d777c7e3e Remove custom coroutine promisifier support 2015-06-15 17:53:58 -04:00
Daniel Lowrey
1a891f54ac Remove streamable support in coroutine resolution 2015-06-15 13:17:27 -04:00
Daniel Lowrey
57c0f222ea Support extended generator error debugging output in PHP7 2015-06-15 11:56:42 -04:00
Daniel Lowrey
deedb4a7fa minor coroutine optimization to avoid extra valid() fcall 2015-06-15 10:58:24 -04:00
Bob Weinand
298357f760 We need to check for Generator::getReturn() in ≥ PHP 7 2015-06-13 18:37:04 +02:00
Daniel Lowrey
f2a0488d87 Add Amp\promises() to coalesce values/promises/promisors to promises 2015-06-09 11:49:22 -04:00
Daniel Lowrey
e923ea3fde minor timeout function/test cleanup 2015-05-31 20:18:42 -04:00
Daniel Lowrey
34088cbf52 Add timeout() function 2015-05-31 20:13:39 -04:00
Daniel Lowrey
0c4f04c6ab Fix missing parameter if coroutine invoked without args 2015-05-27 18:33:57 -04:00
Bob Weinand
6c440b2797 Fix fatal error upon wrong key type 2015-05-27 23:36:22 +02:00
Daniel Lowrey
5e7d6ff095 Fix coroutine fatal if initial advance errored 2015-05-25 12:51:50 -04:00
Daniel Lowrey
e8ac57db31 make function name consistent with others 2015-05-20 20:09:30 -04:00
Daniel Lowrey
29cde175b3 Minor coroutine resolution updates 2015-05-20 19:51:03 -04:00
Daniel Lowrey
c86d6cc930 don't swallow caught exception 2015-05-20 18:29:45 -04:00
Daniel Lowrey
0255049bbb Don't use php7 ReflectionGenerator in PHP5.x branch 2015-05-20 18:19:23 -04:00
Daniel Lowrey
e6f1386b31 Fix double promisor resolve under error condition 2015-05-20 18:16:42 -04:00
Daniel Lowrey
71f9687cff Reactor watcher option "callback_data" renamed "cb_data" 2015-05-20 15:21:59 -04:00
Daniel Lowrey
c7e4e8d0c3 Miscellaneous function changes (more after jump)
- Combinator functions optimized for performance
- Amp\reactor() now accepts an optional assignment parameter for
  modifying the global default event reactor instance to allow for
  third-party Reactor implementations.
- Renamed functions:
    . Amp\getReactor() -> Amp\reactor()
- Removed functions:
    . Amp\chooseReactor()
    . Amp\tick()
    . Amp\immediately()
    . Amp\once()
    . Amp\repeat()
    . Amp\onReadable()
    . Amp\onWritable()
    . Amp\onSignal()
    . Amp\enable()
    . Amp\disable()
    . Amp\cancel()
2015-05-20 15:18:30 -04:00
Daniel Lowrey
9fa6010f19 Optimize non-promise pipe() case 2015-05-19 23:12:32 -04:00
Daniel Lowrey
c8d6a0b5b3 Optimize coroutine resolution for performance 2015-05-19 23:07:29 -04:00
Daniel Lowrey
e3e01c993c Add Amp\Streamable interface for buffered generator resolution 2015-05-19 12:03:26 -04:00
Daniel Lowrey
2a0486cb3c Add Amp\pipe() function to pipe eventual results through a functor 2015-05-19 11:31:01 -04:00
Daniel Lowrey
1ed5e69c52 Move buffering to PromiseStream for custom behavior in extended instances 2015-05-19 01:09:23 -04:00
Daniel Lowrey
953c4612e6 Future -> Deferred 2015-05-19 00:21:33 -04:00
Daniel Lowrey
3af013d418 Expose boolean AMP_DEBUG for performance tuning
Amp Future instances double both as Promisor and Promise
implementations when AMP_DEBUG is defined and set to false.
This switch allows private Promise resolution safety by
default at the expense of performance.

Amp applications should set AMP_DEBUG to false in production
environments to maximize performance.
2015-05-18 23:57:34 -04:00
Daniel Lowrey
0973bba5ef Add PromiseStream to stream Promise updates without callback hell 2015-05-18 17:39:09 -04:00