Aaron Piotrowski
9f68bd4046
Remove Driver::run() and stop()
...
Added Driver::isRunning().
Driver now must be started and stopped through an instance of DriverControl.
2020-09-26 12:50:30 -05:00
Aaron Piotrowski
9a2ebe777a
Merge branch 'kelunik-nested-wait' into v3
2020-09-26 11:40:38 -05:00
Aaron Piotrowski
b35c9f1956
Fix throw from send
2020-09-25 12:57:56 -05:00
Aaron Piotrowski
72b50523a3
Add separate method to await back pressure
2020-09-25 12:32:37 -05:00
Aaron Piotrowski
d48e6bd5d2
Add more class and return types
...
More PHP 7.1 to 8 types added.
2020-09-24 22:17:13 -05:00
Aaron Piotrowski
8e4cc1bbd1
Refactor Pipeline for async/await
2020-09-24 22:14:58 -05:00
Aaron Piotrowski
5f6db028ab
Initial fiber support
2020-09-24 12:53:32 -05:00
Aaron Piotrowski
6dd2b990f8
Revert AsyncGenerator being lazy
2020-09-24 12:53:32 -05:00
Aaron Piotrowski
9a13937fef
Make explicit disposal fail pending promises
...
Destruction of the pipeline does not fail pending promises, but calling dispose() now will.
2020-09-24 12:53:31 -05:00
Aaron Piotrowski
657614c036
Dispose after all pending promises are fulfilled
...
Allows continue() to be called, then dispose(), but the pipeline is not actually disposed until those pending promises are fulfilled.
2020-09-24 12:53:31 -05:00
Aaron Piotrowski
5e521daa16
Rename to Pipeline
2020-09-24 12:53:31 -05:00
Aaron Piotrowski
52d50a5b6d
Revert adding onDisposal() and onCompletion()
...
This largely reverts 6ab9048e717bb1f69f418d82e697a968721115c0.
2020-09-24 12:53:31 -05:00
Aaron Piotrowski
dd0f01f4db
Add onDisposal() and onCompletion() to Stream
...
onCompletion callbacks are invoked if complete() or fail() is called before the stream is disposed.
onDisposal callbacks are invoked if the stream is disposed before being completed or failed.
Forbid failing a stream with DisposedException.
2020-09-24 12:53:31 -05:00
Aaron Piotrowski
42d8ce764b
Add StreamSource::onDisposal()
2020-09-24 12:53:31 -05:00
Aaron Piotrowski
217c31c5ce
Add Promise\succeed() and Promise\fail()
2020-09-24 12:53:31 -05:00
Aaron Piotrowski
ee76c97c51
Add StreamSource::isDisposed()
2020-09-24 12:53:30 -05:00
Aaron Piotrowski
3fb87e2c18
Fix Psalm errors
2020-09-24 12:53:30 -05:00
Aaron Piotrowski
0ddf9a656e
Add Deferred::isResolved() and StreamSource::isComplete()
2020-09-24 12:53:30 -05:00
Aaron Piotrowski
1577906fc1
Make AsyncGenerator execution lazy
...
Matches behavior of Generator which does not start execution until an iteration method is invoked.
2020-09-24 12:53:30 -05:00
Aaron Piotrowski
5d0adebaa2
Add isDebugEnabled function
2020-09-24 12:53:30 -05:00
Aaron Piotrowski
f4cc591988
Feedback update
2020-09-24 12:53:30 -05:00
Aaron Piotrowski
b64b3affc9
Rename yield() to emit()
2020-09-24 12:53:30 -05:00
Aaron Piotrowski
66f0deb563
Drop YieldedValue
2020-09-24 12:53:29 -05:00
Aaron Piotrowski
dae252aea0
Rethrow exceptions from destructors
2020-09-24 12:53:29 -05:00
Aaron Piotrowski
8df006b011
Remove unnecessary internal interface
...
Switched Yielder trait to a concrete class YieldSource.
2020-09-24 12:53:29 -05:00
Aaron Piotrowski
d496c9db24
Resolve promise with YieldedValue
...
A suggested alternative to resolving with [$yieldedValue] since static analysis (specifically Psalm) doesn't play well with that API.
Will revert if Psalm changes or we decide to resolve with [$yieldedValue] anyway.
2020-09-24 12:53:29 -05:00
Aaron Piotrowski
57924690fe
Remove key
2020-09-24 12:53:29 -05:00
Aaron Piotrowski
e1402f8484
Remove StreamModifier
...
I'd rather put this in another repo.
For discoverability, we can add links to the repo in the docblocks here and on amphp.org.
2020-09-24 12:53:29 -05:00
Aaron Piotrowski
704f87ccc8
Use separate objects for stream ops
2020-09-24 12:53:28 -05:00
Aaron Piotrowski
94e01e7e49
Fix apply()
2020-09-24 12:53:28 -05:00
Aaron Piotrowski
3755155e51
Add callback to transform()
...
Suggestion for an apply()-like method.
2020-09-24 12:53:28 -05:00
Aaron Piotrowski
1b4863b7b3
Don't re-wrap stream
2020-09-24 12:53:28 -05:00
Aaron Piotrowski
6283d9bbb7
Intial stream transformations
2020-09-24 12:53:28 -05:00
Aaron Piotrowski
12c97b2561
Add explicit dispose() method to Stream
2020-09-24 12:53:28 -05:00
Aaron Piotrowski
96007f11aa
Add Streams
2020-09-24 12:53:27 -05:00
Niklas Keller
05483cdbef
Enforce timer interval as minimum time to execution ( #319 )
...
Co-authored-by: Aaron Piotrowski <aaron@trowski.com>
2020-07-14 21:45:35 +02:00
Aaron Piotrowski
0b802a501e
Mark repeat watcher as disabled then re-enable when executed ( #325 )
...
Fixes #324 .
2020-07-13 22:29:16 +02:00
Aaron Piotrowski
a04eda397b
Fix potential warning on shutdown in UvDriver
...
Like everything shutdown related, this depends on destruction order and appears to only happen on 7.4+.
2020-07-13 10:12:25 -05:00
Niklas Keller
e2c63c83eb
Add Amp\Iterator\discard ( #315 )
2020-05-06 18:57:29 +02:00
Niklas Keller
17e2c2344c
Improve call / coroutine / wait types, add psalm test
2020-04-30 06:46:52 +02:00
Niklas Keller
a702c85f2f
Add generics for Amp\Promise\wait
2020-04-28 22:35:20 +02:00
Aaron Piotrowski
9b57affd4e
Return self from Delayed ref/unref
2020-04-23 23:43:48 -05:00
Aaron Piotrowski
4faeca163b
Fix ref/unref of Delayed after resolving
2020-04-20 12:01:50 -05:00
Niklas Keller
8ee469be90
Improve type definition for Amp\call
2020-04-19 15:38:36 +02:00
Aaron Piotrowski
0eb8ef438e
Make DriverControl an interface
2020-04-16 11:08:31 -05:00
Aaron Piotrowski
ab409bb254
Rename to DriverControl
2020-04-16 10:59:02 -05:00
Aaron Piotrowski
702aee45d3
Use delegate loop for Promise\wait()
2020-04-16 10:17:37 -05:00
Aaron Piotrowski
a062c3ed26
Update docs
2020-04-16 10:01:53 -05:00
Niklas Keller
5b4d019753
Allow tested calls to Amp\Promise\wait
2020-04-15 22:47:43 +02:00
Jáchym Toušek
2053b42fdb
Improve Deferred::resolve types ( #307 )
2020-04-05 22:37:09 +02:00
Niklas Keller
b6f99cd534
Use conditional psalm types for improved type inference
2020-04-05 22:17:32 +02:00
Niklas Keller
feca077369
Provide useful exception trace in TimeoutCancellationToken ( #303 )
...
Without this, the exception trace is pretty useless, because it only includes Loop::run() and other internal loop calls, giving absolutely no indication which kind of thing had a timeout.
Use debug_backtrace instead of creating the exception early, because it helps with the changes to GC behavior such a change might introduce.
Co-authored-by: Aaron Piotrowski <aaron@trowski.com>
2020-04-04 17:05:26 +02:00
Niklas Keller
8c486b40a8
Add generics to Deferred
2020-04-04 16:35:52 +02:00
Niklas Keller
3d250cbe30
Cover examples with psalm and add @psalm-yield to Promise
2020-04-04 15:49:26 +02:00
Niklas Keller
c34b679142
Remove psalm-suppress for fixed psalm bugs
2020-03-29 14:24:09 +02:00
Niklas Keller
caea418fe8
Increase psalm error level to level 2
2020-03-28 22:20:44 +01:00
Niklas Keller
885cd68828
Increase psalm error level to level 3
2020-03-28 21:55:44 +01:00
Niklas Keller
0e04422dcb
Increase psalm error level to level 4
2020-03-28 20:27:42 +01:00
Niklas Keller
603ce25299
Fix invalid types in doc comments
...
We're on the way to psalm error level 4, but there are still some remaining issues.
2020-03-28 14:32:53 +01:00
Niklas Keller
71d7f5674c
Increase psalm error level to level 5
2020-03-28 14:25:39 +01:00
Niklas Keller
f8efd44684
Add additional types for static analysis
2020-03-28 14:20:27 +01:00
Niklas Keller
01cd49994f
Add further generics for static analysis
2020-03-28 13:52:48 +01:00
Niklas Keller
a75164b66b
Add psalm static analysis on level 6
...
This also fixes mixed types in some cases.
2020-03-28 12:23:46 +01:00
Niklas Keller
d2025541b2
Fix psalm annotation for Amp\Promise
2020-03-21 21:15:39 +01:00
Jáchym Toušek
93fec17736
Improve compatibility with static analysis tools ( #301 )
2020-03-21 21:13:54 +01:00
Aaron Piotrowski
34bcf727dc
Add parameter for custom timeout message ( #299 )
2020-02-28 13:35:37 -06:00
Aaron Piotrowski
2ac3b550c4
Fix array access on null last error
2020-02-10 12:10:57 -06:00
Aaron Piotrowski
193efe7e96
Return null, not -1
2019-11-11 13:23:14 -06:00
Niklas Keller
c73528e839
Expose getCurrentTime as public API
2019-11-11 13:20:38 -06:00
Aaron Piotrowski
dd4d6be677
Remove unneeded method
...
Fix big-O lies in docblock.
2019-10-31 15:41:07 -05:00
Aaron Piotrowski
710f84ccc8
Improve timer cancellation in NativeDriver
2019-10-30 09:41:46 -05:00
Niklas Keller
64e7d10108
Fix cancellation trace recording in TracingDriver
2019-10-26 16:20:56 +02:00
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