Skip to content

Commit 9301b6c

Browse files
committed
% Major refactoring of Finally Handlers and the exception handling mechanism for Scope.
1 parent de45e8c commit 9301b6c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Zend/zend_async_API.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ struct _zend_async_scope_s {
713713
/**
714714
* The method handles an exception delivered to the Scope.
715715
* Its result may either be the cancellation of the Scope or the suppression of the exception.
716-
* If the coroutine parameter is specified, it indicates an attempt to handle an exception from a coroutine.
716+
* If the is_cancellation parameter is FALSE, it indicates an attempt to handle an exception from a coroutine.
717717
* Otherwise, it's an attempt by the user to stop the execution of the Scope.
718718
*
719719
* The method should return true if the exception was handled and the Scope can continue execution.
@@ -723,12 +723,23 @@ struct _zend_async_scope_s {
723723
bool (*catch_or_cancel)(
724724
zend_async_scope_t *scope,
725725
zend_coroutine_t *coroutine,
726+
zend_async_scope_t *from_scope,
726727
zend_object *exception,
727728
bool transfer_error,
728-
const bool is_safely
729+
const bool is_safely,
730+
const bool is_cancellation
729731
);
730732
};
731733

734+
#define ZEND_ASYNC_SCOPE_CLOSE(scope, is_safely) \
735+
((scope)->catch_or_cancel((scope), NULL, NULL, NULL, false, (is_safely), true))
736+
737+
#define ZEND_ASYNC_SCOPE_CANCEL(scope, exception, transfer_error, is_safely) \
738+
((scope)->catch_or_cancel((scope), NULL, NULL, (exception), (transfer_error), (is_safely), true))
739+
740+
#define ZEND_ASYNC_SCOPE_CATCH(scope, coroutine, from_scope, exception, transfer_error, is_safely) \
741+
((scope)->catch_or_cancel((scope), (coroutine), (from_scope), (exception), (transfer_error), (is_safely), false))
742+
732743
#define ZEND_ASYNC_SCOPE_F_CLOSED ZEND_ASYNC_EVENT_F_CLOSED /* scope was closed */
733744
#define ZEND_ASYNC_SCOPE_F_NO_FREE_MEMORY ZEND_ASYNC_EVENT_F_NO_FREE_MEMORY /* scope will not free memory in dispose handler */
734745
#define ZEND_ASYNC_SCOPE_F_DISPOSE_SAFELY (1u << 14) /* scope will be disposed safely */

0 commit comments

Comments
 (0)