Jáchym Toušek
cf12c1c529
Fix annotation ( #288 )
2019-10-26 12:39:02 +02:00
Niklas Keller
5a294f1381
Fix TracingDriver, add TracingDriverTest
2019-10-01 21:39:23 +02:00
Niklas Keller
1657284608
Add TracingDriver for debugging ( #283 )
2019-10-01 21:01:44 +02:00
Aaron Piotrowski
a726db92a5
Only create deferred for backpressure if necessary
2019-09-21 18:30:14 +02:00
Niklas Keller
c45cd5a3a9
Fix backpressure release
...
Previously, backpressure was only released once advance() was called
again. This means the last backpressure item was never free'd in case
the caller knows there are no more items to consume and didn't call
advance() the last time.
2019-09-21 18:30:14 +02:00
c6a775a6c9
Add delay function ( #278 )
2019-08-02 22:37:42 +02:00
Niklas Keller
b57fc2e2b3
Remove PHP 7.1 feature usage for 7.0 compat
2019-08-02 22:16:57 +02:00
Niklas Keller
d4fc8ce7b3
Add CombinedCancellationToken
...
Implementation has been used in http-client before.
2019-08-02 22:09:38 +02:00
Niklas Keller
f824f0df1d
Ignore code coverage for getCurrentTime on 32 bit
2019-05-31 20:42:02 +02:00
Niklas Keller
72a0db5cdc
Warn if time is about to overflow on 32 bit
2019-05-31 20:15:22 +02:00
Niklas Keller
8b38da2f9c
Support 32-bit platforms
2019-05-31 12:59:23 -05:00
Aaron Piotrowski
5316e741b7
Different approach for 32-bit support
...
Prior version made time run backwards… oops.
2019-05-31 12:48:03 -05:00
Aaron Piotrowski
a4fd818e13
Swap sign of returned time on 32-bit systems
2019-05-31 11:40:56 -05:00
Aaron Piotrowski
5dcdd83959
Declare variables as static within function
2019-05-31 11:38:02 -05:00
Niklas Keller
944a2dd29d
Move Coroutine::__destruct to Placeholder
2019-05-31 11:38:02 -05:00
Niklas Keller
58c7bfb689
Improve try / catch nesting
2019-05-31 11:38:02 -05:00
Niklas Keller
c12828081f
Fix exceptions bubbling from Coroutine::__destruct
...
This has been an edge case potentially hiding some exceptions. The tests have been refactored to error if the loop has watchers leaking from one test to another test.
2019-05-31 11:38:02 -05:00
Niklas Keller
a660af794b
Annotate that throwIfRequested might throw CancelledException
2019-05-30 15:13:38 +02:00
Aaron Piotrowski
272f78dcb2
Note method to retreive array of exceptions
2019-03-02 09:22:06 -06:00
Aaron Piotrowski
ef83723a79
Fix signal handler in NativeDriver when used with pcntl_async_signals
...
Fixes #264 .
2019-02-25 18:05:47 -06:00
Masiukevich Maksim
0fd6b8c157
Fix phpdoc types for call / asyncCall ( #260 )
...
Incorrect types were indicated, due to which static analysis led to false positives.
2019-02-05 18:32:32 +01:00
Aaron Piotrowski
c6f8425473
Use a custom priority queue for timers
...
Fixes #220 by allowing immediate removal of the watcher from the queue. Insert and extract is O(log(n)), peeking is O(1), and removal is O(n).
2019-01-24 13:09:11 -06:00
Aaron Piotrowski
b6fc1e12d4
Move nowUpdateNeeded setting to getTimeout()
...
Essentially the same fix as @bwoebi committed, just placed at the source of the problem.
2019-01-21 10:27:49 -06:00
Bob Weinand
c3afc5e977
Fix #256 - Ensure nowUpdateNeeded is set to true after a blocking wait in NativeDriver
...
So that expired timeouts also indeed do trigger immediately instead of in the next tick.
2019-01-21 16:41:30 +01:00
Bob Weinand
7075ef7d74
Fix #251 - 100% CPU usage in NativeDriver
...
Also use better bounds for timer - it must not execute before, but may execute a little later (on my system it were up to 7 ms actually)
2018-12-11 11:31:37 +01:00
Niklas Keller
5622edba37
Implement monotonic timer using PHP 7.3's hrtime()
2018-12-10 20:07:11 +01:00
Aaron Piotrowski
5889f4e0fd
Randomize loop now offset
2018-11-26 21:59:15 +01:00
Aaron Piotrowski
77a12c823b
Add Loop::now()
2018-11-26 21:59:15 +01:00
Sascha-Oliver Prolic
96c2eeaa1f
Add Promise\wrap ( #234 )
2018-11-26 19:36:46 +01:00
Sascha-Oliver Prolic
4a98cc4fde
Add timeoutWithDefault function ( #245 )
2018-11-25 17:56:42 +01:00
Niklas Keller
b73e03bfe2
Rename Iterator\collect to Iterator\toArray
2018-11-25 17:09:50 +01:00
Niklas Keller
22a8332261
Add Iterator\collect
2018-11-25 17:09:50 +01:00
Aaron Piotrowski
c4faf1f347
Update loop time in dispatch() instead of activate()
...
Fixes #243 .
2018-10-14 22:30:31 -05:00
Niklas Keller
fa3fe1d20b
Apply PSR-2
2018-06-18 20:00:01 +02:00
Niklas Keller
5dac863f37
Don't record stack traces in case of AMP_DEBUG not being set ( #218 )
...
Fixes #217 .
2018-04-26 00:32:31 +02:00
Aaron Piotrowski
242d78a6ec
Fix 212 and ignore unreference on invalid watchers ( #216 )
...
Fix #212 & Ignore unreference on invalid watchers
2018-04-12 09:46:52 +02:00
Aaron Piotrowski
9b2fb76442
Free loop handle when destructing EventDriver
...
Relates to #177 .
2018-04-08 13:20:27 -05:00
Aaron Piotrowski
3b12391529
Add note about OR'ing with 4
2018-04-08 13:10:46 -05:00
Aaron Piotrowski
8c8a6da0c2
Invoke watcher callback if events is 0 or 4
...
4 is UV_DISCONNECT
2018-04-06 14:22:39 -05:00
Niklas Keller
c632e40b03
Clarify promise interface
...
Fixes #209 .
2018-03-25 17:27:41 +02:00
Aaron Piotrowski
22eb14d736
Avoid odd ev event nulling behavior
2018-03-20 09:54:22 -05:00
Aaron Piotrowski
992d6e9b39
Return named classes
...
Better for var_dump and stack traces.
2018-01-27 19:47:46 +01:00
Aaron Piotrowski
4bbe141718
Hide resolution methods
2018-01-27 19:47:46 +01:00
Niklas Keller
3f08f615d8
Fix segfault with ev on shutdown, fixes amphp/parallel#3
2017-12-19 18:27:18 +01:00
Aaron Piotrowski
be3ae73a45
Drop multiple definitions of Deferred and Emitter
...
Closes #144 , #157 , #173 , #189 , #190 .
2017-12-16 00:00:56 -06:00
Niklas Keller
0cb033084a
Fix formatStacktrace notice
2017-12-07 18:23:19 +01:00
Niklas Keller
98cfaa63ca
Remove unused variables
2017-12-05 08:48:56 +01:00
Aaron Piotrowski
4ef9af6dff
Check against "false"
2017-12-02 11:15:06 -06:00
Aaron Piotrowski
e3b0b9a0c7
Update backtrace formatting
2017-12-02 11:14:49 -06:00
Aaron Piotrowski
745a95ba67
Define AMP_DEBUG through environment
2017-12-02 10:23:12 -06:00
Markus Staab
34bf671f13
Automatically add \ for buitins ( #186 )
...
Fixes #185 .
2017-11-29 13:36:50 +01:00
Bob Weinand
7837d8ce08
Fix #172 - Preserve Promise order within combinator functions
2017-10-10 15:37:31 +02:00
Niklas Keller
df15b07fb3
Replace driver with dummy driver and collect cycles on loop switch
...
This solves https://github.com/amphp/dns/issues/66 . Circular references might otherwise be collected later and __destruct operations using the Loop accessor might cancel watchers on the wrong loop.
2017-10-08 12:52:30 +02:00
Niklas Keller
a247757535
Ignore only warnings for interrupted syscalls in NativeDriver
...
Fixes #160 .
2017-09-19 18:53:39 +02:00
Niklas Keller
7a04dc5c21
Fix EventDriver warnings and bugs
...
Fixes #163 , #159 .
2017-09-17 12:18:04 +02:00
Aaron Piotrowski
05491a57c9
Optimize fast-finishing/failing coroutines
2017-08-04 22:50:19 -05:00
Niklas Keller
8f5fb52525
Shut up php-cs-fixer
...
See https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/2948 .
2017-07-29 23:43:24 +02:00
Bob Weinand
5e93318d85
Fix issue with the loop not terminating with only unreferenced watchers
2017-07-09 09:28:32 +02:00
Aaron Piotrowski
5f3e21a4a4
Add TimeoutCancellationToken
2017-06-13 12:41:47 -05:00
Niklas Keller
c7fcbd96dc
Make NullCancellationToken final
2017-06-09 17:22:21 +02:00
Aaron Piotrowski
9757b39fab
Use call in LazyPromise and make class final
2017-06-09 10:18:06 -05:00
Aaron Piotrowski
f83d36dfe5
Update promise docblocks
2017-06-06 12:57:03 -05:00
Aaron Piotrowski
7a05fe1316
Use static function for rethrow
2017-06-05 00:21:45 -05:00
Aaron Piotrowski
6ec8757698
Use references instead of function invocation
2017-06-05 00:19:34 -05:00
Aaron Piotrowski
b354b04779
Fix code style
2017-06-05 00:10:13 -05:00
Aaron Piotrowski
02eb0340f1
Use anonymous classes in Deferred and Emitter
2017-06-04 23:59:23 -05:00
Niklas Keller
332869987b
Implement NullCancellationToken
2017-05-24 10:34:54 +02:00
Aaron Piotrowski
cd252e4165
Invoke callback on all non-zero statuses
2017-05-24 00:09:04 -05:00
Niklas Keller
ef6c2b10ee
Micro-optimize interval = 0 if
2017-05-23 20:17:34 +02:00
Niklas Keller
38ef4d9ffa
Fix issues with interval = 0 repeat watchers, fixes #131
2017-05-23 19:46:23 +02:00
Niklas Keller
dbc853c3f1
Fix timers with interval = 0 in NativeDriver
2017-05-22 19:54:14 +02:00
Aaron Piotrowski
5bca41ade4
Cleaner coroutine continuation
2017-05-22 12:28:29 -05:00
Niklas Keller
5dad46f297
Implement additional cancellation token methods
2017-05-22 19:26:09 +02:00
Bob Weinand
7e500548df
Merge pull request #133 from amphp/env-driver
...
Allow setting the loop driver via the env
2017-05-20 18:12:17 +02:00
Bob Weinand
26dfafe00c
Avoid coroutine callstack explosion upon yielding succeeded Promises
2017-05-20 16:31:49 +02:00
Niklas Keller
9d18a1f8bd
Readd missing depth property
2017-05-20 09:46:01 +02:00
Niklas Keller
e8e26d79e7
Revert "Drop max continuation depth"
...
This reverts commit cdf28fa938
.
As streams always buffer before applying backpressure, these might
result in a stack overflow. Another example is file streaming with
the blocking driver, which always immediately succeeds.
2017-05-20 09:40:56 +02:00
Niklas Keller
e589f2d935
Remove fallback part from error messages
2017-05-19 16:51:20 +02:00
Niklas Keller
28bb6068f1
Allow setting the loop driver via the env
2017-05-19 16:17:11 +02:00
Bob Weinand
4fe48c8aec
Fix #132 (TypeError calling Driver::disable())
2017-05-19 15:57:49 +02:00
Niklas Keller
39dd36efdc
Fix cancellation token example
2017-05-16 21:46:52 +02:00
Aaron Piotrowski
be2a9f8c07
Merge pull request #130 from amphp/cancellation
...
Implement cancellation primitives, resolves #125
2017-05-16 11:32:42 -05:00
Aaron Piotrowski
086f045003
Remove event to stream map
...
Unnecessary as the watcher object is available in cancel().
2017-05-16 11:22:40 -05:00
Bob Weinand
6e52f3e211
Fix potential issues when operating on destroyed uv handles in shutdown sequence
2017-05-16 18:17:12 +02:00
Aaron Piotrowski
de783b8eb1
Do not call uv_* functions on expired timers
2017-05-15 12:41:43 -05:00
Niklas Keller
61a7596106
Implement cancellation primitives, resolves #125
2017-05-14 23:07:49 +02:00
Aaron Piotrowski
40299959bf
Remove calls to uv_close()
...
Watchers are closed on garabage collection if necessary.
2017-05-13 10:12:03 -05:00
Aaron Piotrowski
51ab8cb134
Only poll again on UV_EAGAIN
2017-05-13 10:11:00 -05:00
Aaron Piotrowski
3f1f9f41ca
Do not call uv_close() if other watchers on the same stream exist
2017-05-11 10:39:31 -05:00
Niklas Keller
50b37b23ef
Add asyncCall
2017-05-03 15:21:49 +02:00
Niklas Keller
28820fa459
Ignore __destruct for coverage
2017-05-02 19:30:34 +02:00
Niklas Keller
783fe8c4f4
✅ Add asyncCoroutine and ReactPromise tests
2017-05-02 18:59:52 +02:00
Niklas Keller
141875b133
🔥 Kill pipe and capture
...
Use Amp\call instead.
2017-05-02 18:32:59 +02:00
Aaron Piotrowski
835e617054
More stream → iterator
...
Hopefully that's all of them…
2017-05-02 07:07:43 +02:00
Aaron Piotrowski
da9b724f5b
getIterator → iterate
2017-05-02 07:07:43 +02:00
Aaron Piotrowski
91c8da9fec
Replace more occurrences of stream
2017-05-02 07:07:43 +02:00
Aaron Piotrowski
f78328822c
Allow for debugging of double iterator completion
2017-05-02 07:07:43 +02:00
Aaron Piotrowski
45481a710c
Squash leftover Stream references
2017-05-02 07:07:33 +02:00
Aaron Piotrowski
38d53304ae
Stream → Iterator
2017-05-02 07:07:20 +02:00
Aaron Piotrowski
4992d3ebac
Update stream tests
2017-05-02 07:06:20 +02:00
Aaron Piotrowski
a096a36f9a
Emitter::resolve → Emitter::complete
2017-05-02 07:04:30 +02:00
Aaron Piotrowski
7e6eb3689e
Update stream functions
2017-05-02 07:04:30 +02:00
Aaron Piotrowski
4935dddc84
Refactor Streams
...
Dropped original Stream interface in favor of the Iterator interface. Eliminates subscriber timing issues and simplifies Stream usage.
2017-05-02 07:04:10 +02:00
Niklas Keller
1286087c06
Rename Pause to Delayed
...
Pause doesn't cover the delayed value use case.
2017-05-02 07:02:02 +02:00
Aaron Piotrowski
45476b76a4
Reuse watcher resources when possible
...
Previously, disabling the sole read or write watcher for a stream would result in a duplicate UV-watcher for that stream being created. This keeps track of which UV-watchers are associated with a stream until the watcher is cancelled (not just disabled).
2017-04-24 19:19:22 -05:00
Aaron Piotrowski
e1491b1925
Handle invalid yield like a failed promise
2017-04-24 13:08:30 -05:00
Aaron Piotrowski
34192ceca5
Drop Coroutine::dispose()
2017-04-24 11:10:05 -05:00
Niklas Keller
79ab41e5bf
Update php-cs-fixer to version 2 and upgrade rules
...
This also fixes the code style according to the new rules.
2017-04-24 16:22:02 +02:00
Niklas Keller
e9d48a68d5
Rename createRunnable to asyncCoroutine and createCallable to coroutine
2017-04-24 15:27:04 +02:00
Niklas Keller
dc21d094c5
Throw error in case the loop throws during wait
2017-04-24 15:27:04 +02:00
Niklas Keller
e1c63c62f4
Minor documentation changes
2017-04-24 15:27:04 +02:00
Niklas Keller
65a37484a2
Replace UnionTypeError with factory function + minor doc changes
2017-04-24 15:27:04 +02:00
Niklas Keller
70e63a3748
Fix code style according to new rules
2017-04-24 15:27:04 +02:00
Niklas Keller
dfa40f5b00
Rename wrap to createRunnable and coroutine to createCallable
2017-04-24 15:27:04 +02:00
Niklas Keller
4f8b656513
Document wrap and coroutine better by explicitly naming the differences
2017-04-24 15:27:04 +02:00
Aaron Piotrowski
a562d6b20f
Use same poll for read and write watchers
...
Changed values of Watcher constants to match UV constants because it was easier that way. :-D
2017-04-21 10:54:53 -05:00
Aaron Piotrowski
fdeb427717
Use simple assignment if queue is empty
...
The common case is for the queue to be empty at the start of the tick, so a call to array_merge() can be avoided in most cases.
2017-04-20 11:26:13 -05:00
Aaron Piotrowski
628d8cbab1
Set next "now" at the beginning of watcher activation
2017-04-20 11:13:17 -05:00
Aaron Piotrowski
4792bf52fe
Emulate "now" behavior of libuv/libev in NativeDriver and EventDriver
...
Timers created while not running when using NativeDriver and EventDriver will include the elapsed time before run() is called. This matches the behavior of EvDriver and UvDriver. Addresses #113 .
2017-04-19 17:21:23 -05:00
Aaron Piotrowski
89570e8f6d
Move Watcher to Loop namespace
2017-04-18 09:38:16 -05:00
Ciaran Kelly
0e4d4b492e
Add missing namespace declarations
2017-04-15 23:16:50 +01:00
Bob Weinand
61b88a780e
Merge remote-tracking branch 'origin/kelunik-v2-review'
2017-04-15 00:42:07 +02:00
Aaron Piotrowski
38a6066e53
Remove Message
2017-04-14 09:23:47 -05:00
Niklas Keller
fed09e42ac
Fix line lengths
2017-04-13 18:49:32 +02:00
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