1
0
mirror of https://github.com/danog/amp.git synced 2024-11-27 04:24:42 +01:00
Commit Graph

495 Commits

Author SHA1 Message Date
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
Bob Weinand
e7d629e58f Fix signals not being dispatched in NativeLoop
This was the case when at least one expired and non-expired timer existed.
2016-08-14 22:29:30 +02:00
Niklas Keller
cef92e9770 Doc fixes for Coroutine 2016-08-14 19:17:08 +02:00
Bob Weinand
dcf17e3f98 Optimize Producer & remove wait until first subscribe
Also delay first emit in Emitter until next tick
2016-08-14 16:57:17 +02:00
Bob Weinand
08d65bcd63 Make Subscriber not caring about $id type 2016-08-14 04:47:48 +02:00
Bob Weinand
80265b726e Do not have final methods in Struct, functions may need to be overridden 2016-08-14 04:41:47 +02:00
Aaron Piotrowski
42d9b25c3d Temp var unnecessary 2016-08-13 10:24:55 -05:00
Aaron Piotrowski
7bc08b9a6a Replace leftover LogicExceptions exceptions with Error 2016-08-12 16:58:53 -05:00
Aaron Piotrowski
2ff32c2d6b Remove unnecessary default parameter values 2016-08-12 16:38:36 -05:00
Aaron Piotrowski
66c38e1480 Refactor Amp\coroutine()
Any function can now be passed to this function, which now returns a function returning an awaitable.
2016-08-12 14:50:44 -05:00
Aaron Piotrowski
69ec812bc0 Require PHP 7 2016-08-11 14:52:40 -05:00
Aaron Piotrowski
658edf33f7 Use Closure::fromCallable() in 7.1 2016-08-11 13:33:51 -05:00
Aaron Piotrowski
ea66677a50 Update for Driver changes in spec 2016-08-06 08:58:37 -05:00
Aaron Piotrowski
aa7b76e842 Add awaitable/coroutine-aware loop functions
These functions mirror the standard loop methods, but run returned Generators as coroutines and invoke rethrow() on returned awaitables.
2016-08-02 12:48:32 -05:00
Aaron Piotrowski
13908fe2e5 Add concat() function 2016-08-01 11:10:59 -05:00
Aaron Piotrowski
9055f159e7 Revert some() to v1 behavior 2016-07-31 00:31:04 -05:00
Aaron Piotrowski
19e6440897 Fix native loop timers 2016-07-25 10:09:40 -05:00
Aaron Piotrowski
c2caca9d02 Fix functions using Subscriber as Awaitable
Use PHP_INT_MAX instead of 0 for infinite interval() count.
2016-07-20 08:53:18 -05:00
Aaron Piotrowski
7adc7d8452 Remove missed emit() default value 2016-07-20 08:52:19 -05:00
Aaron Piotrowski
8e794ba1d7 Fix stream() 2016-07-19 15:24:05 -05:00
Aaron Piotrowski
24142496d8 Rethrow subscriber callback exceptions from loop 2016-07-19 15:13:56 -05:00
Bob Weinand
1642bf9195 s/settle/any/ which now returns [$errors, $succeeds] 2016-07-19 21:39:09 +02:00
Aaron Piotrowski
bec838b693 Remove leftover exception class
No longer needed as Subscriber is not an awaitable.
2016-07-19 13:30:28 -05:00
Aaron Piotrowski
70123b9a44 Update Producer::resolve(); fix emitting observable 2016-07-19 13:19:44 -05:00
Aaron Piotrowski
9839343bbb Remove default value from emit 2016-07-19 13:10:15 -05:00
Aaron Piotrowski
13a6fc59c4 Producer::init() -> private 2016-07-19 12:42:58 -05:00
Aaron Piotrowski
32b4721c5e Subscriber no longer implements Awaitable 2016-07-19 12:40:16 -05:00
Aaron Piotrowski
90d744537e protected -> private in internal traits 2016-07-19 12:32:43 -05:00
Aaron Piotrowski
3e170639c3 Remove final from Observer and Subscriber 2016-07-19 11:58:20 -05:00
Aaron Piotrowski
dad93a6da0 Merge branch 'observable' into v2 2016-07-18 23:29:19 -05:00
Aaron Piotrowski
b9d554dd7b Add more functions 2016-07-18 23:23:25 -05:00
Aaron Piotrowski
c561197d1d Remove unused v1 files 2016-07-18 23:22:07 -05:00
Aaron Piotrowski
ade997688a Merge branch 'awaitable' into v2 2016-07-18 23:20:05 -05:00
Aaron Piotrowski
3f654cbd5b Initial tests plus some fixes 2016-07-12 11:20:06 -05:00
Bob Weinand
3603d5b1ec EvLoop::enabled() -> supported() 2016-06-26 17:35:25 +02:00
Aaron Piotrowski
2a1fde0b44 Add automatic loop factory bootstrap 2016-06-23 23:37:06 -05:00
Aaron Piotrowski
4ed8e65468 Cleaner resolution 2016-06-16 23:27:14 -05:00
Aaron Piotrowski
92767755ee Avoid loosing exception thrown from generator after invalid yield 2016-06-16 22:44:32 -05:00
Aaron Piotrowski
f553e4f08b Improve coroutine continuation
Duplicated some code for faster coroutine continuation.
2016-06-14 23:26:59 -05:00
Aaron Piotrowski
ae182165e5 Remove circular reference check 2016-06-14 21:53:50 -05:00
Aaron Piotrowski
60d560d70e Add $className param to capture(); other cleanup 2016-06-14 21:40:04 -05:00
Aaron Piotrowski
986b69907f No need to call keepalive within EvLoop
Loop class handles the details necessary to stop the loop if no reference watchers exist.
2016-06-09 12:59:18 -05:00
Aaron Piotrowski
33338324d4 Add UvLoop 2016-06-09 12:57:46 -05:00
Aaron Piotrowski
666cc42a5f Better ref/unref in EvLoop; fix EvLoopTest 2016-06-08 16:03:37 -05:00
Aaron Piotrowski
543d1c5e66 Fix repeat timer interval 2016-06-08 12:08:00 -05:00
Aaron Piotrowski
a49d333f1b Add EvLoop; Split shared components into Loop 2016-06-08 09:22:14 -05:00
Aaron Piotrowski
757778c848 Fix check if signal was disabled
Plus some minor tweaks
2016-06-08 00:15:36 -05:00
Aaron Piotrowski
8e31310921 Fix repeat timer memory leak 2016-06-07 12:40:35 -05:00
Aaron Piotrowski
93424c1c6e Enable events in next tick 2016-06-07 12:24:53 -05:00
Aaron Piotrowski
f940934a0b Update for latest standard changes
Plus some minor tweaks and more docs.
2016-06-07 00:18:59 -05:00
Bob Weinand
c9af067b46 Fix delays/intervals being able equal to zero 2016-06-04 00:10:47 +02:00
Aaron Piotrowski
666bb332e1 Fix some bugs, refactor disable/unreference 2016-06-03 10:00:29 -05:00
Aaron Piotrowski
808ce32e3c Fix leftover mentions of Disposable 2016-06-02 17:11:25 -05:00
Aaron Piotrowski
548a9fd556 Fix bug when emitting failed awaitable and waiting for a subscriber 2016-06-02 17:05:22 -05:00
Aaron Piotrowski
7fb57141d2 Cleanup yielded value handling 2016-06-02 10:46:22 -05:00
Aaron Piotrowski
5715bec9e1 Refactor functions with Emitter 2016-06-02 10:43:46 -05:00
Aaron Piotrowski
cef5c90168 Drop disposable interface; rename dispose() to unsubscribe() 2016-06-02 10:42:22 -05:00
Aaron Piotrowski
acbe2c8237 Add Registry; support streams with multiple watchers 2016-06-02 09:45:04 -05:00
Aaron Piotrowski
055d7d4c52 Update docblocks 2016-06-01 12:18:11 -05:00
Aaron Piotrowski
cd6939db5a Build awaitable in when() 2016-06-01 12:10:46 -05:00
Aaron Piotrowski
b705c144c6 Minor tweaks 2016-06-01 12:06:43 -05:00
Aaron Piotrowski
906d6db47a Update docblocks 2016-06-01 11:37:12 -05:00
Aaron Piotrowski
c4e9a19095 Rename Emitter to Producer; add new Emitter class
Emitter uses a coroutine to emit values. Updated examples.
2016-06-01 11:19:19 -05:00
Aaron Piotrowski
cc431a0374 Prevent emit without subscribers 2016-05-31 23:02:59 -05:00
Aaron Piotrowski
eb49e6e8ff Resolve emit with observable result instead of emitting
Emitting another observable will emit values from the emitted observable, then resolve the awaitable returned from emit with the observable result
2016-05-31 16:23:01 -05:00
Aaron Piotrowski
a52e1e4c33 Rename Observer methods 2016-05-31 14:45:14 -05:00
Aaron Piotrowski
1b079bb336 Fix Observer 2016-05-30 00:34:44 -05:00
Aaron Piotrowski
57e25f9354 Simpler implementation 2016-05-29 11:46:58 -05:00
Aaron Piotrowski
da3bbdf90c Null default for Success 2016-05-29 10:40:00 -05:00
Aaron Piotrowski
4a2baa670e Subscriber model 2016-05-27 15:44:01 -05:00
Aaron Piotrowski
ca827319ec Standard updates and more
Update for changes in async-interop/event-loop.
Do not invalidate delay and defer on disable.
Better watcher ID generation.
Throw if enabling invalid watcher.
2016-05-27 10:16:36 -05:00
Aaron Piotrowski
99eecc1a3f Refactor 2016-05-26 18:20:05 -05:00
Aaron Piotrowski
3edab2dfd3 Put Loop::get() back
Why do I keep thinking null uses the current loop... bah
2016-05-26 18:15:33 -05:00
Aaron Piotrowski
dd70850682 Remove driver argument 2016-05-26 00:09:50 -05:00
Aaron Piotrowski
ae225835f2 Drop exception namespace 2016-05-25 23:24:06 -05:00
Aaron Piotrowski
a68bde6449 Eliminate watcher constructors 2016-05-25 23:21:49 -05:00
Aaron Piotrowski
b436a56869 Remove unused property 2016-05-24 12:09:52 -05:00
Aaron Piotrowski
a9362780ed Initial commit 2016-05-24 11:47:14 -05:00
Aaron Piotrowski
ccec7acc94 Remove Exception namespace 2016-05-24 10:39:19 -05:00
Aaron Piotrowski
5cd2c33d5c Fix defer queue invocation 2016-05-24 09:36:16 -05:00
Aaron Piotrowski
6d263ffb84 Drop Awaitable from namespace 2016-05-23 22:48:28 -05:00
Aaron Piotrowski
8b42994ec9 Fix exception creation 2016-05-23 21:36:29 -05:00
Aaron Piotrowski
13e807d564 Throw on repeated resolution 2016-05-23 21:32:41 -05:00
Aaron Piotrowski
6fc6ad1ab5 Throw instead of returning Failure object 2016-05-23 10:19:48 -05:00
Aaron Piotrowski
28577cf6e6 Add Pause; update for timer watcher changes in loop 2016-05-23 00:44:35 -05:00
Aaron Piotrowski
27a4569b8b Improve defer queue invocation 2016-05-23 00:37:56 -05:00
Aaron Piotrowski
e1a2e99ca8 Avoid namespace lookup on built-in functions 2016-05-22 23:08:31 -05:00
Aaron Piotrowski
55e0971be1 Update for changes in async-interop
Remove use of Registry; switch Yoda conditionals
2016-05-22 22:59:09 -05:00
Aaron Piotrowski
378990fe86 Use $exception instead of passing as callback data
Less code this way
2016-05-22 13:43:37 -05:00
Aaron Piotrowski
918e792093 Fix LazyAwaitable 2016-05-22 13:42:38 -05:00
Aaron Piotrowski
b572f9be40 Rename and move Promise 2016-05-22 13:26:53 -05:00
Aaron Piotrowski
de3ada9014 Cleanup functions; rename any() to first(); remove resolve() 2016-05-22 10:53:13 -05:00
Aaron Piotrowski
b4ea37576e Execute after CoroutineResult 2016-05-22 09:25:40 -05:00
Niklas Keller
0b954b2515 Fix wait to reuse current default loop 2016-05-22 10:57:31 +02:00
Niklas Keller
9f4d38471d Remove 'fail', clean up signatures 2016-05-22 10:57:10 +02:00
Aaron Piotrowski
1864b3cbe6 Refactor coroutine return for 5.x 2016-05-22 00:11:03 -05:00
Aaron Piotrowski
9c541b0faa Rename Lazy to LazyAwaitable 2016-05-21 23:47:50 -05:00
Aaron Piotrowski
a6fbc13d89 Remove defined check 2016-05-21 12:19:48 -05:00
Aaron Piotrowski
345bf78ac2 Double-quote strings 2016-05-21 12:12:55 -05:00
Aaron Piotrowski
a309a243c2 Fix formatting 2016-05-21 12:07:08 -05:00
Aaron Piotrowski
c7f64ce2c0 Initial commit 2016-05-21 09:44:52 -05:00
Aaron Piotrowski
deb45e2cc2 Initial commit 2016-05-19 11:13:07 -05:00
Bob Weinand
4f2161da5f Fix notices in NativeReactor; prepare tag 1.2.2 2016-05-12 14:54:59 +02:00