New API: Sync\waitAll()
@@ -195,6 +195,33 @@ static const zend_function_entry swow_sync_wait_group_methods[] = {
PHP_FE_END
};
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Swow_Sync_waitAll, ZEND_RETURN_VALUE, 0, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "-1")
+ZEND_END_ARG_INFO()
+
+static PHP_FUNCTION(Swow_Sync_waitAll)
+{
+ zend_long timeout = -1;
+ cat_bool_t ret;
+
+ ZEND_PARSE_PARAMETERS_START(0, 1)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(timeout)
+ ZEND_PARSE_PARAMETERS_END();
+
+ ret = cat_coroutine_wait_all_ex(timeout);
+
+ if (UNEXPECTED(!ret)) {
+ swow_throw_exception_with_last(swow_sync_exception_ce);
+ RETURN_THROWS();
+ }
+}
+
+static const zend_function_entry swow_sync_functions[] = {
+ PHP_FENTRY(Swow\\Sync\\waitAll, PHP_FN(Swow_Sync_waitAll), arginfo_Swow_Sync_waitAll, 0)
+ PHP_FE_END
+};
+
int swow_sync_module_init(INIT_FUNC_ARGS)
{
swow_sync_wait_reference_ce = swow_register_internal_class(
@@ -216,5 +243,9 @@ int swow_sync_module_init(INIT_FUNC_ARGS)
"Swow\\Sync\\Exception", swow_exception_ce, NULL, NULL, NULL, cat_true, cat_true, NULL, NULL, 0
);
+ if (zend_register_functions(NULL, swow_sync_functions, NULL, MODULE_PERSISTENT) != SUCCESS) {
+ return FAILURE;
+ }
+
return SUCCESS;
}
