You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Whether Coroutine\Channel and Coroutine\Defer are supported #1
onFinally() method is not run in the swpan() method, and it is not very easy to release resources;
Isn't it? This method can be used anywhere.
like: currentCoroutine()->onFinally().
Although I haven’t written such a test yet, it’s possible that not everything works :)
We could also create an Async\onFinally function to avoid writing such a long expression:
But there's a deeper issue here.
Currently, onFinally handlers are executed in a separate coroutine, not in the one where they were registered. This is done to improve code safety and prevent finally handlers from blocking coroutine termination.
On the other hand, it would be useful to be able to execute code at the end of a function without switching to another coroutine. In this sense, onFinally is not the same.
I would prefer to add a new syntactic construct to PHP that directly implements this scenario.
However, the new syntactic construct is not limited to asynchronous code — it applies to PHP as a whole. Therefore, for now, onFinally handlers are a way to achieve the same goal.
Activity
EdmondDantes commentedon Jun 23, 2025
Good afternoon. Of course, channels are planned to be supported.
defer is already supported as the
onFinally()method.https://github.com/true-async/php-async/blob/main/tests/coroutine/014-coroutine_onFinally_basic.phpt
tw2066 commentedon Jun 24, 2025
Good morning!
I appreciate your prompt response.
onFinally()method is not run in theswpan()method, and it is not very easy to release resources;EdmondDantes commentedon Jun 24, 2025
Isn't it? This method can be used anywhere.
like:
currentCoroutine()->onFinally().Although I haven’t written such a test yet, it’s possible that not everything works :)
We could also create an
Async\onFinallyfunction to avoid writing such a long expression:But there's a deeper issue here.
Currently,
onFinallyhandlers are executed in a separate coroutine, not in the one where they were registered. This is done to improve code safety and prevent finally handlers from blocking coroutine termination.On the other hand, it would be useful to be able to execute code at the end of a function without switching to another coroutine. In this sense,
onFinallyis not the same.I would prefer to add a new syntactic construct to PHP that directly implements this scenario.
However, the new syntactic construct is not limited to asynchronous code — it applies to PHP as a whole. Therefore, for now, onFinally handlers are a way to achieve the same goal.
tw2066 commentedon Jun 24, 2025
Thank you for your answer.
EdmondDantes commentedon Jun 24, 2025
Thank you for the helpful questions!
#98: Coverage phase 2 — future.c 80.38% → 85.80%
ci: debug-bugfix — no-JIT vs JIT passes + richer core dump for #1 (#118)
ci: rr record --chaos + reverse-debug for #1 (#118)
ci: debug-bugfix — test #1 under off/function/tracing JIT (#118)