Uh oh!
There was an error while loading. Please reload this page.
Improve async() by making its promises cancellable - #20
Conversation
Uh oh!
There was an error while loading. Please reload this page.
azjezz
commented
Jan 7, 2022
I think this following case would fail 🤔 $promise = async(function (): int {
echo'a'; await(async(function(): void {
await(async(function(): void {
await(sleep(2)); })());
})());
echo'b';
returntime();
})(); |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
208a782 to
ab2e7b8Compare794c7d8 to
1dd9138Compareasync() by making its promises cancelabled86b691 to
8a65d99CompareSimonFrings
commented
Feb 24, 2022
@WyriHaximus looks good to me, only thing I just noticed is that the description for cancellation is missing inside the |
Uh oh!
There was an error while loading. Please reload this page.
8a65d99 to
25810abCompareWyriHaximus
commented
Feb 24, 2022
@SimonFrings done 👍 |
25810ab to
9dfeea4Compare
clue
left a comment
There was a problem hiding this comment.
@WyriHaximus Some great progress in here, love this feature and how beautifully it aligns with our existing cancellation logic (#9 / #13)!
Added a number of smaller remarks below, otherwise looks like an excellent addition! Semantics make a lot of sense to me, so I'd love to get this in as is, but I do see some room for follow-up discussions once we address reactphp/promise#56 in the future 👍
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
WyriHaximus
commented
Mar 2, 2022
@clue Yes this one is the missing link we need to make this package fully fit into our ecosystem. As mentioned on some of your comments, I will create a follow up PR to utilize WeakMap and WeakReference where possible to put the garbage collector in charge of cleaning up promise <-> fiber references. But for the sake of landing this feature, and requiring more time to fully test the behavior there I didn't update this PR with that. |
async() by making its promises cancelableasync() by making its promises cancellable
clue
left a comment
There was a problem hiding this comment.
@WyriHaximus Some good progress! I agree the WeakMap implementation can be left up to a future PR, only added a couple of remarks below, otherwise LGTM!
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
9df8ce5 to
f400d20CompareSince `async()` returns a promise and those are normally cancelable, implementing this puts them in line with the rest of our ecosystem. As such the following example will throw a timeout exception from the canceled `sleep()` call.
```php
$promise = async(static function (): int {
echo 'a';
await(sleep(2));
echo 'b';
return time();
})();
$promise->cancel();
await($promise);
````
This builds on top of reactphp#15, reactphp#18, reactphp#19, reactphp#26, reactphp#28, reactphp#30, and reactphp#32.
clue
left a comment
There was a problem hiding this comment.
@WyriHaximus Thanks for the update, changes LGTM, so let's get this shipped! ![]()
Since
async()returns a promise and those are normally cancelable, implementing this puts them in line with the rest of our ecosystem. As such the following example will throw a timeout exception from the canceledsleep()call.This builds on top of #15, #18, #19, #26, #28, #30, and #32.