Continue internal Queue
execution also after fiber is suspended
#229
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This simple changeset updates the internal
Queue
class to continue execution also after a fiber is suspended (PHP 8.1+). In particular, this is needed to make our new Async v4 package compatible with Promise v3 (reactphp/async#48).The added test cases are the gist of why our Async integration currently fails with Promise v3 only (reactphp/async#48), but other than that I agree that they might look a bit weird. I don't particularly care about how an individual promise behaves if a fiber is suspended (perfectly reasonable to argue in either direction), but the original version has some severe problems as all promises start to fail once a fiber is suspended.
This is the minimal changeset I could come up with, but I understand that this reverts parts of the iterative logic introduced in #28/#82/#86. The test suite confirms my changes do not break any of the known assumptions and in fact bring the execution order more in line with how Promise v2 and v1 work (this causes the build error in friends-of-reactphp/mysql#157 and likely also in reactphp/socket#214). I would suggest we should look into this iterative logic and its consequences again in a follow-up PR if we see a need for this. Until we can come up with more specific test cases that highlight now the original iterative logic is needed, I would argue that merging this as is to move forward with reactphp/async#48 seems reasonable.