1
0
mirror of https://github.com/danog/amp.git synced 2024-11-30 04:29:08 +01:00
Commit Graph

597 Commits

Author SHA1 Message Date
Niklas Keller
5e545301cd Rename Listener to StreamIterator 2017-04-13 18:20:46 +02:00
Niklas Keller
3a42254300 Make Watcher implement Struct 2017-04-13 18:05:59 +02:00
Niklas Keller
3e8b37f21f Remove Amp\Stream\interval and add delay option to fromIterable 2017-04-13 18:05:41 +02:00
Niklas Keller
b810ff1034 Use eval to prevent multiple definitions warnings for Emitter and Deferred 2017-04-13 18:04:51 +02:00
Aaron Piotrowski
a0b8de40fb Null deferred refs 2017-04-07 12:50:01 -05:00
Bob Weinand
f100d9cd8b Fix possible double resolutions 2017-04-07 18:47:44 +02:00
Bob Weinand
c52279065d Remove unnecessary use of temporary variables 2017-04-07 18:09:39 +02:00
Aaron Piotrowski
e43f9afc8f Refactor functions to remove circular refs
This will provide for faster garbage collection of unused promises/deferreds/etc.
2017-04-07 10:51:57 -05:00
Aaron Piotrowski
97dd8d933e Forward UV error to loop error handler and disable watchers 2017-04-06 11:18:33 -05:00
Aaron Piotrowski
d01ee68dd2 Null circular reference on resolution 2017-04-06 09:24:21 -05:00
Aaron Piotrowski
cdf28fa938 Drop max continuation depth
It seems unlikely a real-world application would run out of memory due to call stack depth for normal coroutine continuations (that is, where infinite recursion is not root problem). Hopefully time will not prove me wrong…
2017-03-30 23:45:54 -05:00
Niklas Keller
8caae2253f Allow recording stacktraces to debug double resolution 2017-03-29 17:25:44 +02:00
Aaron Piotrowski
2f7e9a0746 Run returned generator as coroutine from onResolve and onEmit callbacks 2017-03-27 18:37:55 -05:00
Aaron Piotrowski
173549ebba Halt recursive runs with each call to stop, addresses #84 2017-03-27 11:42:51 -05:00
Aaron Piotrowski
cb717952f1 Validate number of required promises 2017-03-27 11:42:11 -05:00
Aaron Piotrowski
c464e070e4 s/fail/succeed 2017-03-26 12:53:26 -05:00
Aaron Piotrowski
67f9f4a569 Drop lift and Promise\map; add required param to Promise\some 2017-03-26 12:34:34 -05:00
Niklas Keller
ff5fef4b93 Fix UV executing multiple IO watchers in different ticks, fixes #85 2017-03-25 19:52:17 +01:00
Niklas Keller
2aa91a6c25 Rename Stream::listen to Stream::onEmit 2017-03-21 18:29:51 +01:00
Niklas Keller
ce269fa516 Rename Promise::when to Promise::onResolve, resolves #77 2017-03-21 17:23:37 +01:00
Niklas Keller
a954f73d8e Update namespacing to be compatible with what's actually used 2017-03-18 21:52:23 +01:00
Aaron Piotrowski
39b95255d2 Reduce code duplication in Coroutine
Hot path is still duplicated for performance, but conversion of non-promise values to promises should be a single method.
2017-03-15 19:10:23 -05:00
Aaron Piotrowski
86b494a5c4 Throw Error if registering signal handler fails 2017-03-15 19:08:00 -05:00
Aaron Piotrowski
a927b3cb06 Separate functions into Promise and Stream namespaces 2017-03-15 19:02:04 -05:00
Niklas Keller
ea67e113b2 Add test for loop accessor 2017-03-15 08:40:58 +01:00
Niklas Keller
01c58ae90e Fix EvDriver with throwing onSignal callback 2017-03-15 08:33:04 +01:00
Niklas Keller
73149b933f Ignore DriverFactory for code coverage 2017-03-14 22:33:45 +01:00
Aaron Piotrowski
6b9ec609c1 Add UnionTypeError 2017-03-14 13:15:31 -05:00
Aaron Piotrowski
44c5a1b1dc Cleanup React promise adaption 2017-03-14 13:15:31 -05:00
Niklas Keller
e92bd57030 Remove outdated @throws RuntimeException 2017-03-14 19:05:38 +01:00
Niklas Keller
c13e8e3a66 Use Error instead of InvalidArgumentException, remove test file 2017-03-14 18:44:44 +01:00
Niklas Keller
ee11b70395 Fix remaining InvalidWatcherError renames 2017-03-14 18:24:14 +01:00
Aaron Piotrowski
1dadd4f0da InvalidWatcherException → InvalidWatcherError 2017-03-14 11:48:27 -05:00
Aaron Piotrowski
2ab7403ded More code coverage ignores; throw Error instead of DomainException 2017-03-14 11:44:19 -05:00
Niklas Keller
35ac983c53 Add appropriate coverage ignores to Driver.php 2017-03-14 11:01:11 +01:00
Aaron Piotrowski
d7353d4d8f Catch watcher callback exceptions individually
Exceptions thrown from watcher callbacks are now forwarded to the loop error handler without ending the current tick. Fixes #74.
2017-03-14 00:20:05 -05:00
Niklas Keller
20acaf123e Remove unsused code from InvalidWatcherException, add handle tests for drivers 2017-03-13 13:56:46 +01:00
Aaron Piotrowski
f187d4b31a Accept React promises in rethrow, wait, timeout, pipe, and capture
Fixes #75.
2017-03-13 07:17:06 +01:00
Aaron Piotrowski
8b7fb9ece3 Merge pull request #72 from amphp/issue-68
Implement yielding arrays as implicit all operator
2017-03-12 22:45:31 -05:00
Niklas Keller
77bd05b807 Fix tests and Producer React adaption 2017-03-12 22:09:19 +01:00
Niklas Keller
0006c6cb56 Fix async-interop docblock leftover 2017-03-12 21:39:17 +01:00
Niklas Keller
e8ea4e2ba9 Implement yielding arrays as implicit all operator, fixes #68 2017-03-12 19:42:25 +01:00
Aaron Piotrowski
2cc4cf9d0b Fix use statement order 2017-03-12 12:23:48 -05:00
Aaron Piotrowski
f040e8801e Fast return on void watcher callback 2017-03-12 12:23:27 -05:00
Aaron Piotrowski
cd4328ab48 Merge branch 'react-compatibility' 2017-03-12 11:38:48 -05:00
Pieter Hordijk
2db7bed1b6 Fixed typos an promise -> a promise 2017-03-12 17:36:07 +01:00
Niklas Keller
d748855a51 Fix some risky tests 2017-03-12 17:33:46 +01:00
Niklas Keller
f5f9410ec0 Rename Factory to DriverFactory, rename supported to isSupported 2017-03-12 11:25:21 +01:00
Niklas Keller
766b3224d1 Rename drivers to have a Driver instead of Loop suffix 2017-03-12 11:21:44 +01:00
Aaron Piotrowski
a98fe5cdf6 Rethrow React promise rejections
Adapt React promises returned from watcher callbacks to promises so that rethrow is called on them.
2017-03-11 09:17:55 -06:00
Aaron Piotrowski
7ad10f5d7d Add support for React promises 2017-03-11 09:17:43 -06:00
Aaron Piotrowski
7ebe70e0ae Fix docblock param formatting
Callable prototypes make alignment a mess… maybe something better can be done.
2017-03-10 23:08:40 -06:00
Aaron Piotrowski
2a9d7cb97b Remove unnecessary parameter 2017-03-10 22:59:11 -06:00
Aaron Piotrowski
85de9f1f1e Remove missed wrap call 2017-03-10 16:23:29 -06:00
Aaron Piotrowski
1fea860a05 Run watcher callbacks as coroutines within drivers 2017-03-10 16:03:41 -06:00
Aaron Piotrowski
ca30af4d22 More type declarations in loop component 2017-03-10 15:46:12 -06:00
Aaron Piotrowski
1929715b97 Remove driver nullability 2017-03-10 15:34:52 -06:00
Aaron Piotrowski
754a29e86c Remove promise error handler
Exceptions thrown from when callbacks are now forwarded directly to the loop error handler.
2017-03-10 15:32:58 -06:00
Niklas Keller
be34c49a2d Fixup all remaining issues, tests pass locally 2017-03-10 22:20:28 +01:00
Niklas Keller
dd8993b98e Fix AsyncInterop → Amp in ErrorHandler 2017-03-10 22:09:49 +01:00
Niklas Keller
0be9ae9ade Switch from AsyncInterop\Promise to Amp\Promise 2017-03-10 21:58:46 +01:00
Niklas Keller
e64bbfb9f5 Add Loop::set, auto-wrapping, fixup things 2017-03-10 21:31:57 +01:00
Niklas Keller
21561661a2 Fixup after repository merge 2017-03-10 19:19:32 +01:00
Niklas Keller
f4f9008ca0 Merge amphp/amp repository into amphp/amp 2017-03-10 18:26:17 +01:00
Aaron Piotrowski
72378e2b82 Add Amp\call() 2017-02-22 15:52:30 -06:00
Aaron Piotrowski
bb51720818 Always use persistent flag for timer
cancel() is called when delay timers are executed anyway, so it doesn't matter what the flags are for the event.
2017-02-16 23:39:11 -06:00
Aaron Piotrowski
9073f6c999 Docblock cleanup 2017-02-16 22:36:32 -06:00
Aaron Piotrowski
d7e8a9de84 Calling stop() in nested loop should not stop outer loop 2017-02-16 22:20:10 -06:00
Aaron Piotrowski
b72e504eab Ensure correct argument order in multi-argument lift 2017-02-09 22:34:24 -06:00
Aaron Piotrowski
3861c6b5da Simpler each and filter implementation 2017-02-09 22:17:45 -06:00
Aaron Piotrowski
5dade2443f Fix error in Message with empty stream 2017-01-31 17:30:05 -06:00
Aaron Piotrowski
5f284b2f70 Refactor Message, add Iterator 2017-01-31 17:09:38 -06:00
Niklas Keller
a69bf4d3a0 Improve type hints / types 2017-01-16 17:39:24 +01:00
Aaron Piotrowski
0631560c65 Merge pull request #62 from amphp/drop-choose
Drop Amp\choose
2017-01-15 08:49:11 -06:00
Aaron Piotrowski
e3cb5dc385 Merge pull request #54 from amphp/ex-msg
Make exception messages more generic
2017-01-15 08:48:56 -06:00
Aaron Piotrowski
84917e7786 Add Message and Listener::getBuffered() 2017-01-13 18:46:32 -06:00
Aaron Piotrowski
df901a0305 Remove stream() method from Listener 2017-01-13 18:12:38 -06:00
Niklas Keller
8f245fa677 Drop Amp\choose 2017-01-13 19:09:17 +01:00
Aaron Piotrowski
a643f9a260 Remove last consumed value from listener before drain 2017-01-11 20:13:12 -06:00
Niklas Keller
6312ac15aa Fix invalid watcher exception construction 2017-01-11 14:28:27 +01:00
Aaron Piotrowski
4c48037295 Add reference/unreference methods to Pause 2017-01-08 01:15:57 -06:00
Aaron Piotrowski
ae28eae552 Lazy → LazyPromise 2017-01-08 01:02:11 -06:00
Aaron Piotrowski
5ad1fdb38b Add more Listener tests and kill another Humbug mutant 2017-01-08 00:22:07 -06:00
Niklas Keller
3b46c168a5 Improve tests and kill some Humbug mutants 2017-01-07 22:55:34 +01:00
Aaron Piotrowski
2976ebdbb5 Throw on consecutive calls to Listener::advance(); better property names 2017-01-07 12:31:36 -06:00
Aaron Piotrowski
cf5ebb1408 Better error message when emitting after resolve 2017-01-07 12:25:04 -06:00
Aaron Piotrowski
cba57dd81e Simplify PrivatePromise and PrivateStream 2017-01-07 12:24:40 -06:00
Niklas Keller
ae69e92266 Update to promise 0.4.0 and event-loop 0.5.0, add humbug config 2017-01-07 13:47:45 +01:00
Niklas Keller
568183b261 Update to event-loop 0.5.0 2017-01-07 13:45:03 +01:00
Aaron Piotrowski
a47fc2bc01 Don't call uv_stop()
libuv will actually stop mid-tick, making the behavior inconsistent with the other loop implementations.
2017-01-06 10:50:05 -06:00
Aaron Piotrowski
e169bb649c Remove unnecessary temp variable 2017-01-06 10:21:58 -06:00
Aaron Piotrowski
fbdc611e44 Activate watchers at begging of tick instead of end 2017-01-06 10:15:54 -06:00
Aaron Piotrowski
3e0cd85b67 Stop watchers in EvLoop::__destruct() to avoid segfault 2017-01-05 17:38:33 -06:00
Aaron Piotrowski
9706815714 Fix signals in multiple loops using event and ev extensions with epoll backend 2017-01-05 17:32:03 -06:00
Aaron Piotrowski
02c2fcf0fa Add implementation using event extension 2017-01-05 14:08:33 -06:00
Aaron Piotrowski
06e50bdb88 Fix docblock 2017-01-05 12:39:34 -06:00
Aaron Piotrowski
80900189c9 Fix visibility of deactivate() 2017-01-05 12:39:10 -06:00
Aaron Piotrowski
9ff73ac681 Swap production and dev definitions for Deferred and Emitter 2017-01-04 10:24:51 -06:00
Aaron Piotrowski
210b6ff258 Observable → Stream 2017-01-03 19:10:27 -06:00
Aaron Piotrowski
a872f14fd4 Drop Amp\range(), add Amp\observableFromIterable() 2016-12-30 12:50:09 -06:00
Bob Weinand
26a707ed94 Always put the watcher back upon re-activation 2016-12-30 00:55:06 +01:00
Aaron Piotrowski
b5d5b8dff1 Drop loop wrapper functions 2016-12-29 16:57:08 -06:00
Aaron Piotrowski
5651240615 Update to promise spec v0.3
Dropped strict-types due to spec requiring weak types in callbacks.
2016-12-29 16:29:27 -06:00
Aaron Piotrowski
81f6d3f94f Avoid pcntl bug with closures 2016-12-29 14:40:12 -06:00
Aaron Piotrowski
6f2a238087 Merge branch 'event-loop-v0.4' into uv 2016-12-28 23:50:30 -06:00
Aaron Piotrowski
b535a72161 Update for loop standard changes 2016-12-28 23:11:08 -06:00
Bob Weinand
04300eba89 Remove redundant destructor 2016-12-29 03:06:53 +01:00
Bob Weinand
7e875298b8 Use getInfo() in __debugInfo() 2016-12-29 01:50:41 +01:00
Aaron Piotrowski
8ab3918974 Remove \UV::RUN_ONCE if not blocking. 2016-12-28 16:16:09 -06:00
Aaron Piotrowski
225c0703ee Merge branch 'event-loop-v0.4' into uv 2016-12-28 13:02:20 -06:00
Aaron Piotrowski
583a50fab7 Update for loop standard changes 2016-12-28 12:59:04 -06:00
Niklas Keller
2a65c0735b Fix docblock for Placeholder::when 2016-12-23 23:48:24 +01:00
Bob Weinand
ef9216a00a Do not block in Loop::dispatch() after Loop::stop() 2016-12-18 21:56:47 +01:00
Aaron Piotrowski
bc1ae1822c Unreference watcher in Amp\timout() 2016-12-17 08:28:19 -06:00
Aaron Piotrowski
11f1c7e7c4 Amp\lazy() → Amp\Lazy
Plus some tests!
2016-12-15 18:50:33 -06:00
Aaron Piotrowski
93ad513ab1 Remove dead code
Deferred and Postponed will never throw from the functions they define.
2016-12-15 17:34:30 -06:00
Aaron Piotrowski
6e97e6630d Fix some function bugs and add more tests 2016-12-15 17:31:57 -06:00
Niklas Keller
1bbcadaedd Rename Observer::next to Observer::advance 2016-12-13 20:37:51 +01:00
Niklas Keller
1299e51ca6 Add tests for InvalidYieldError, improve key display
Without something like var_export, null and false are casted to an empty string.
2016-12-11 17:08:17 +01:00
Niklas Keller
e4d97caad7 Fix whitespace 2016-12-11 16:17:51 +01:00
Niklas Keller
2ba73e90fc Fix documentation to point to when instead of then and done 2016-12-11 16:16:12 +01:00
Niklas Keller
bd7e84a138 Improve error messages 2016-12-11 16:12:42 +01:00
Daniel Lowrey
e3cdea2fce Make exception messages more generic 2016-12-09 12:22:37 -05:00
Aaron Piotrowski
f95412770b Lazy promise bugfix 2016-11-14 14:10:44 -06:00
Aaron Piotrowski
9927ad5b4f Awaitable → Promise 2016-11-14 13:59:21 -06:00
Aaron Piotrowski
7f5142be88 Fix map() return type 2016-09-09 18:05:01 -05:00
Aaron Piotrowski
973a08c26b Update for loop standard v0.3 2016-09-09 17:38:22 -05:00
Aaron Piotrowski
759af93112 Missed static; remove unused import 2016-09-07 12:24:49 -05:00
Aaron Piotrowski
0992eaea89 CallableFromMethod -> CallableMaker 2016-08-30 10:34:17 -05:00
Aaron Piotrowski
448391531e Add CallableFromMethod trait 2016-08-29 18:35:49 -05:00
Aaron Piotrowski
220c969e12 Allow Amp\*() loop callbacks to return values
Asserting that the function be void if not a Generator turned out to be just annoying rather than helpful.
2016-08-29 12:40:13 -05:00
Aaron Piotrowski
44aee8de47 Restrict callback returns to void or Generator 2016-08-26 16:29:57 -05:00
Aaron Piotrowski
edf2984863 Update Observable-based functions
Some of the changes to Observables broke functions using them.
2016-08-23 13:22:24 -05:00
Aaron Piotrowski
f46912d387 Fix bug on null emits 2016-08-23 13:18:56 -05:00
Aaron Piotrowski
6e1c1db5a6 Drop special behavior when emitting an observable 2016-08-23 13:17:59 -05:00
Aaron Piotrowski
3ce0c0dd37 Resolve with boolean, not emitted value 2016-08-23 12:50:16 -05:00
Bob Weinand
c89f10eef0 Make Observer::drain() public 2016-08-23 16:21:05 +02:00
Aaron Piotrowski
5f1354bf1a Add drain() method to Observer 2016-08-23 08:50:04 -05:00
Aaron Piotrowski
ddefcf21f9 Implement Observable in Success and Failure 2016-08-22 16:21:47 -05:00
Aaron Piotrowski
ef143534e3 Fix issue with resolved Observer not receiving all values 2016-08-22 10:54:39 -05:00
Aaron Piotrowski
96e1178b89 Code, docblock, and comment cleanup 2016-08-17 22:25:54 -05:00
Aaron Piotrowski
a8d7d71a1a Drop Future and Producer 2016-08-17 21:17:31 -05:00
Aaron Piotrowski
d4e83490c2 Drop unsubscribing from Observable 2016-08-17 21:11:03 -05:00
Aaron Piotrowski
2317a3aa37 Unsubscribe from emitted observable if failed 2016-08-16 16:31:09 -05:00
Aaron Piotrowski
84c2572e0a Prevent fail call after resolution 2016-08-16 13:30:32 -05:00
Aaron Piotrowski
bdc26e1e8b Combine use statements 2016-08-16 13:07:51 -05:00
Aaron Piotrowski
dae4eb90da Better Emitter fix; fail observable if emitted awaitable fails 2016-08-16 13:07:38 -05:00
Aaron Piotrowski
a8a5a1b3a5 Fix Emitter 2016-08-16 02:28:47 -05:00
Aaron Piotrowski
888229d667 Use strict types 2016-08-15 23:46:26 -05:00
Bob Weinand
6a87658ad8 Remove bogus .coveralls.yml file 2016-08-15 15:41:28 +02:00