diff --git a/CHANGELOG.md b/CHANGELOG.md index e9edced..7f913ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,13 +32,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed the `spawnWith()` function for interaction with the `ScopeProvider` and `SpawnStrategy` interface ### Changed +- **Breaking Change: Function Renaming** - Major API reorganization for better consistency: + - `awaitAllFailFirst()` → `awaitAllOrFail()` + - `awaitAllWithErrors()` → `awaitAll()` + - `awaitAnyOfFailFirst()` → `awaitAnyOfOrFail()` + - `awaitAnyOfWithErrors()` → `awaitAnyOf()` +- **Breaking Change: `awaitAll()` Return Format** - New `awaitAll()` (formerly `awaitAllWithErrors()`) now returns `[results, exceptions]` tuple: + - First element `[0]` contains array of successful results + - Second element `[1]` contains array of exceptions from failed coroutines + - **Migration**: Update from `$results = awaitAll($coroutines)` to `[$results, $exceptions] = awaitAll($coroutines)` - **LibUV requirement increased to ≥ 1.44.0** - Requires libuv version 1.44.0 or later to ensure proper UV_RUN_ONCE behavior and prevent busy loop issues that could cause high CPU usage - **Async Iterator API**: - Proper handling of `REWIND`/`NEXT` states in a concurrent environment. The iterator code now stops iteration in coroutines if the iterator is in the process of changing its position. - Added functionality for proper handling of exceptions from `Zend iterators` (`\Iterator` and `generators`). - An exception that occurs in the iterator can now be handled by the iterator’s owner. + An exception that occurs in the iterator can now be handled by the iterator's owner. ## [0.2.0] - 2025-07-01 diff --git a/async.c b/async.c index 829fdf2..9fafc43 100644 --- a/async.c +++ b/async.c @@ -293,7 +293,7 @@ PHP_FUNCTION(Async_await) zend_async_waker_destroy(coroutine); } -PHP_FUNCTION(Async_awaitAny) +PHP_FUNCTION(Async_awaitAnyOrFail) { zval * futures; zend_object * cancellation = NULL; @@ -397,7 +397,7 @@ PHP_FUNCTION(Async_awaitFirstSuccess) RETURN_ARR(return_array); } -PHP_FUNCTION(Async_awaitAll) +PHP_FUNCTION(Async_awaitAllOrFail) { zval * futures; zend_object * cancellation = NULL; @@ -437,7 +437,7 @@ PHP_FUNCTION(Async_awaitAll) RETURN_ARR(results); } -PHP_FUNCTION(Async_awaitAllWithErrors) +PHP_FUNCTION(Async_awaitAll) { zval * futures; zend_object * cancellation = NULL; @@ -488,7 +488,7 @@ PHP_FUNCTION(Async_awaitAllWithErrors) RETURN_ARR(return_array); } -PHP_FUNCTION(Async_awaitAnyOf) +PHP_FUNCTION(Async_awaitAnyOfOrFail) { zval * futures; zend_object * cancellation = NULL; @@ -532,7 +532,7 @@ PHP_FUNCTION(Async_awaitAnyOf) RETURN_ARR(results); } -PHP_FUNCTION(Async_awaitAnyOfWithErrors) +PHP_FUNCTION(Async_awaitAnyOf) { zval * futures; zend_object * cancellation = NULL; diff --git a/async.stub.php b/async.stub.php index 554fea5..ac1c802 100644 --- a/async.stub.php +++ b/async.stub.php @@ -37,17 +37,17 @@ function protect(\Closure $closure): mixed {} function await(Awaitable $awaitable, ?Awaitable $cancellation = null): mixed {} -function awaitAny(iterable $triggers, ?Awaitable $cancellation = null): mixed {} +function awaitAnyOrFail(iterable $triggers, ?Awaitable $cancellation = null): mixed {} function awaitFirstSuccess(iterable $triggers, ?Awaitable $cancellation = null): mixed {} -function awaitAll(iterable $triggers, ?Awaitable $cancellation = null, bool $preserveKeyOrder = true): array {} +function awaitAllOrFail(iterable $triggers, ?Awaitable $cancellation = null, bool $preserveKeyOrder = true): array {} -function awaitAllWithErrors(iterable $triggers, ?Awaitable $cancellation = null, bool $preserveKeyOrder = true, bool $fillNull = false): array {} +function awaitAll(iterable $triggers, ?Awaitable $cancellation = null, bool $preserveKeyOrder = true, bool $fillNull = false): array {} -function awaitAnyOf(int $count, iterable $triggers, ?Awaitable $cancellation = null, bool $preserveKeyOrder = true): array {} +function awaitAnyOfOrFail(int $count, iterable $triggers, ?Awaitable $cancellation = null, bool $preserveKeyOrder = true): array {} -function awaitAnyOfWithErrors(int $count, iterable $triggers, ?Awaitable $cancellation = null, bool $preserveKeyOrder= true, bool $fillNull = false): array {} +function awaitAnyOf(int $count, iterable $triggers, ?Awaitable $cancellation = null, bool $preserveKeyOrder = true, bool $fillNull = false): array {} function delay(int $ms): void {} diff --git a/async_arginfo.h b/async_arginfo.h index 13f4911..a3ca625 100644 --- a/async_arginfo.h +++ b/async_arginfo.h @@ -24,34 +24,34 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_await, 0, 1, IS_MIXED, 0) ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAny, 0, 1, IS_MIXED, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAnyOrFail, 0, 1, IS_MIXED, 0) ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") ZEND_END_ARG_INFO() -#define arginfo_Async_awaitFirstSuccess arginfo_Async_awaitAny +#define arginfo_Async_awaitFirstSuccess arginfo_Async_awaitAnyOrFail -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAll, 0, 1, IS_ARRAY, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAllOrFail, 0, 1, IS_ARRAY, 0) ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserveKeyOrder, _IS_BOOL, 0, "true") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAllWithErrors, 0, 1, IS_ARRAY, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAll, 0, 1, IS_ARRAY, 0) ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserveKeyOrder, _IS_BOOL, 0, "true") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fillNull, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAnyOf, 0, 2, IS_ARRAY, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAnyOfOrFail, 0, 2, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0) ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserveKeyOrder, _IS_BOOL, 0, "true") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAnyOfWithErrors, 0, 2, IS_ARRAY, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAnyOf, 0, 2, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0) ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") @@ -92,12 +92,12 @@ ZEND_FUNCTION(Async_spawnWith); ZEND_FUNCTION(Async_suspend); ZEND_FUNCTION(Async_protect); ZEND_FUNCTION(Async_await); -ZEND_FUNCTION(Async_awaitAny); +ZEND_FUNCTION(Async_awaitAnyOrFail); ZEND_FUNCTION(Async_awaitFirstSuccess); +ZEND_FUNCTION(Async_awaitAllOrFail); ZEND_FUNCTION(Async_awaitAll); -ZEND_FUNCTION(Async_awaitAllWithErrors); +ZEND_FUNCTION(Async_awaitAnyOfOrFail); ZEND_FUNCTION(Async_awaitAnyOf); -ZEND_FUNCTION(Async_awaitAnyOfWithErrors); ZEND_FUNCTION(Async_delay); ZEND_FUNCTION(Async_timeout); ZEND_FUNCTION(Async_currentContext); @@ -114,12 +114,12 @@ static const zend_function_entry ext_functions[] = { ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "suspend"), zif_Async_suspend, arginfo_Async_suspend, 0, NULL, NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "protect"), zif_Async_protect, arginfo_Async_protect, 0, NULL, NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "await"), zif_Async_await, arginfo_Async_await, 0, NULL, NULL) - ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAny"), zif_Async_awaitAny, arginfo_Async_awaitAny, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAnyOrFail"), zif_Async_awaitAnyOrFail, arginfo_Async_awaitAnyOrFail, 0, NULL, NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitFirstSuccess"), zif_Async_awaitFirstSuccess, arginfo_Async_awaitFirstSuccess, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAllOrFail"), zif_Async_awaitAllOrFail, arginfo_Async_awaitAllOrFail, 0, NULL, NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAll"), zif_Async_awaitAll, arginfo_Async_awaitAll, 0, NULL, NULL) - ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAllWithErrors"), zif_Async_awaitAllWithErrors, arginfo_Async_awaitAllWithErrors, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAnyOfOrFail"), zif_Async_awaitAnyOfOrFail, arginfo_Async_awaitAnyOfOrFail, 0, NULL, NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAnyOf"), zif_Async_awaitAnyOf, arginfo_Async_awaitAnyOf, 0, NULL, NULL) - ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAnyOfWithErrors"), zif_Async_awaitAnyOfWithErrors, arginfo_Async_awaitAnyOfWithErrors, 0, NULL, NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "delay"), zif_Async_delay, arginfo_Async_delay, 0, NULL, NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "timeout"), zif_Async_timeout, arginfo_Async_timeout, 0, NULL, NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "currentContext"), zif_Async_currentContext, arginfo_Async_currentContext, 0, NULL, NULL) diff --git a/tests/await/005-awaitAny_basic.phpt b/tests/await/005-awaitAnyOrFail_basic.phpt similarity index 77% rename from tests/await/005-awaitAny_basic.phpt rename to tests/await/005-awaitAnyOrFail_basic.phpt index 06bd515..8aead0f 100644 --- a/tests/await/005-awaitAny_basic.phpt +++ b/tests/await/005-awaitAnyOrFail_basic.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAny() - basic usage with multiple coroutines +awaitAnyOrFail() - basic usage with multiple coroutines --FILE-- getMessage() . "\n"; diff --git a/tests/await/010-awaitAll_basic.phpt b/tests/await/010-awaitAllOrFail_basic.phpt similarity index 75% rename from tests/await/010-awaitAll_basic.phpt rename to tests/await/010-awaitAllOrFail_basic.phpt index 2fb887c..f2e7f7c 100644 --- a/tests/await/010-awaitAll_basic.phpt +++ b/tests/await/010-awaitAllOrFail_basic.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAll() - basic usage with multiple coroutines +awaitAllOrFail() - basic usage with multiple coroutines --FILE-- getMessage() . "\n"; diff --git a/tests/await/012-awaitAllWithErrors_basic.phpt b/tests/await/012-awaitAll_basic.phpt similarity index 86% rename from tests/await/012-awaitAllWithErrors_basic.phpt rename to tests/await/012-awaitAll_basic.phpt index 3095495..661a412 100644 --- a/tests/await/012-awaitAllWithErrors_basic.phpt +++ b/tests/await/012-awaitAll_basic.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAllWithErrors() - basic usage with mixed success and error +awaitAll() - basic usage with mixed success and error --FILE-- = 2 ? "OK" : "FALSE: ".count($results); echo "Count of results: $countOfResults\n"; diff --git a/tests/await/015-awaitAnyOf_count_zero.phpt b/tests/await/015-awaitAnyOfOrFail_count_zero.phpt similarity index 69% rename from tests/await/015-awaitAnyOf_count_zero.phpt rename to tests/await/015-awaitAnyOfOrFail_count_zero.phpt index ffec806..f4ed891 100644 --- a/tests/await/015-awaitAnyOf_count_zero.phpt +++ b/tests/await/015-awaitAnyOfOrFail_count_zero.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAnyOf() - count is zero +awaitAnyOfOrFail() - count is zero --FILE-- = 2 ? "OK" : "FALSE: ".count($result[0]); $countOfErrors = count($result[1]) == 1 ? "OK" : "FALSE: ".count($result[1]); diff --git a/tests/await/017-awaitAnyOfWithErrors_all_success.phpt b/tests/await/017-awaitAnyOf_all_success.phpt similarity index 80% rename from tests/await/017-awaitAnyOfWithErrors_all_success.phpt rename to tests/await/017-awaitAnyOf_all_success.phpt index d9869e9..a092868 100644 --- a/tests/await/017-awaitAnyOfWithErrors_all_success.phpt +++ b/tests/await/017-awaitAnyOf_all_success.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAnyOfWithErrors() - all coroutines succeed +awaitAnyOf() - all coroutines succeed --FILE-- = 2 ? "OK" : "FALSE: ".count($result[0]); $countOfErrors = count($result[1]) == 0 ? "OK" : "FALSE: ".count($result[1]); diff --git a/tests/await/018-awaitAll_double_free.phpt b/tests/await/018-awaitAllOrFail_double_free.phpt similarity index 85% rename from tests/await/018-awaitAll_double_free.phpt rename to tests/await/018-awaitAllOrFail_double_free.phpt index 3b06e67..a87ddab 100644 --- a/tests/await/018-awaitAll_double_free.phpt +++ b/tests/await/018-awaitAllOrFail_double_free.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAll() - test for double free issue with many coroutines +awaitAllOrFail() - test for double free issue with many coroutines --FILE-- = 2 ? "OK" : "FALSE: ".count($results); echo "Count of results: $countOfResults\n"; diff --git a/tests/await/024-awaitAnyOfWithErrors_iterator.phpt b/tests/await/024-awaitAnyOf_iterator.phpt similarity index 90% rename from tests/await/024-awaitAnyOfWithErrors_iterator.phpt rename to tests/await/024-awaitAnyOf_iterator.phpt index 80d19c3..d314104 100644 --- a/tests/await/024-awaitAnyOfWithErrors_iterator.phpt +++ b/tests/await/024-awaitAnyOf_iterator.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAnyOfWithErrors() - with Iterator +awaitAnyOf() - with Iterator --FILE-- = 2 ? "OK" : "FALSE: ".count($result[0]); $countOfErrors = count($result[1]) == 1 ? "OK" : "FALSE: ".count($result[1]); diff --git a/tests/await/025-awaitAll_generator.phpt b/tests/await/025-awaitAllOrFail_generator.phpt similarity index 83% rename from tests/await/025-awaitAll_generator.phpt rename to tests/await/025-awaitAllOrFail_generator.phpt index 3d82832..0dd553b 100644 --- a/tests/await/025-awaitAll_generator.phpt +++ b/tests/await/025-awaitAllOrFail_generator.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAll() - with Generator +awaitAllOrFail() - with Generator --FILE-- = 2 ? "OK" : "FALSE: ".count($results); echo "Count of results: $countOfResults\n"; diff --git a/tests/await/030-awaitAnyOfWithErrors_generator.phpt b/tests/await/030-awaitAnyOf_generator.phpt similarity index 86% rename from tests/await/030-awaitAnyOfWithErrors_generator.phpt rename to tests/await/030-awaitAnyOf_generator.phpt index 71b7654..0dd6cd8 100644 --- a/tests/await/030-awaitAnyOfWithErrors_generator.phpt +++ b/tests/await/030-awaitAnyOf_generator.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAnyOfWithErrors() - with Generator +awaitAnyOf() - with Generator --FILE-- = 2 ? "OK" : "FALSE: ".count($result[0]); $countOfErrors = count($result[1]) == 1 ? "OK" : "FALSE: ".count($result[1]); diff --git a/tests/await/031-awaitAll_with_interruption.phpt b/tests/await/031-awaitAllOrFail_with_interruption.phpt similarity index 91% rename from tests/await/031-awaitAll_with_interruption.phpt rename to tests/await/031-awaitAllOrFail_with_interruption.phpt index a65415d..b3c07a9 100644 --- a/tests/await/031-awaitAll_with_interruption.phpt +++ b/tests/await/031-awaitAllOrFail_with_interruption.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAll() - With an unexpected interruption of execution. +awaitAllOrFail() - With an unexpected interruption of execution. --FILE-- throw new Exception("Unexpected interruption")); $iterator = new TestIterator($functions); -$results = awaitAll($iterator); +$results = awaitAllOrFail($iterator); $countOfResults = count($results) == 3 ? "OK" : "FALSE: ".count($results); echo "Count of results: $countOfResults\n"; diff --git a/tests/await/032-awaitAny_with_interruption.phpt b/tests/await/032-awaitAnyOrFail_with_interruption.phpt similarity index 91% rename from tests/await/032-awaitAny_with_interruption.phpt rename to tests/await/032-awaitAnyOrFail_with_interruption.phpt index 428e5fd..ce844d0 100644 --- a/tests/await/032-awaitAny_with_interruption.phpt +++ b/tests/await/032-awaitAnyOrFail_with_interruption.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAny() - With an unexpected interruption of execution. +awaitAnyOrFail() - With an unexpected interruption of execution. --FILE-- throw new Exception("Unexpected interruption")); $iterator = new TestIterator($functions); -$result = awaitAny($iterator); +$result = awaitAnyOrFail($iterator); echo "Result: $result\n"; echo "end\n"; diff --git a/tests/await/034-awaitAll_preserve_key_order.phpt b/tests/await/034-awaitAllOrFail_preserve_key_order.phpt similarity index 85% rename from tests/await/034-awaitAll_preserve_key_order.phpt rename to tests/await/034-awaitAllOrFail_preserve_key_order.phpt index 4331b19..5aff864 100644 --- a/tests/await/034-awaitAll_preserve_key_order.phpt +++ b/tests/await/034-awaitAllOrFail_preserve_key_order.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAll() - with fillNull parameter +awaitAllOrFail() - with fillNull parameter --FILE-- getMessage() . "\n"; diff --git a/tests/await/052-awaitAny_iterator_exception.phpt b/tests/await/052-awaitAnyOrFail_iterator_exception.phpt similarity index 88% rename from tests/await/052-awaitAny_iterator_exception.phpt rename to tests/await/052-awaitAnyOrFail_iterator_exception.phpt index f67e1ad..083a2b4 100644 --- a/tests/await/052-awaitAny_iterator_exception.phpt +++ b/tests/await/052-awaitAnyOrFail_iterator_exception.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAny() - Exception in iterator current() should stop process immediately +awaitAnyOrFail() - Exception in iterator current() should stop process immediately --FILE-- getMessage() . "\n"; diff --git a/tests/await/054-awaitAll_generator_exception.phpt b/tests/await/054-awaitAllOrFail_generator_exception.phpt similarity index 82% rename from tests/await/054-awaitAll_generator_exception.phpt rename to tests/await/054-awaitAllOrFail_generator_exception.phpt index d62eb2e..79f3863 100644 --- a/tests/await/054-awaitAll_generator_exception.phpt +++ b/tests/await/054-awaitAllOrFail_generator_exception.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAll() - Exception in generator body should stop process immediately +awaitAllOrFail() - Exception in generator body should stop process immediately --FILE-- getMessage() . "\n"; diff --git a/tests/await/055-awaitAny_generator_exception.phpt b/tests/await/055-awaitAnyOrFail_generator_exception.phpt similarity index 83% rename from tests/await/055-awaitAny_generator_exception.phpt rename to tests/await/055-awaitAnyOrFail_generator_exception.phpt index 9b0ae1e..9c3d8b0 100644 --- a/tests/await/055-awaitAny_generator_exception.phpt +++ b/tests/await/055-awaitAnyOrFail_generator_exception.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAny() - Exception in generator body should stop process immediately +awaitAnyOrFail() - Exception in generator body should stop process immediately --FILE-- getMessage() . "\n"; diff --git a/tests/await/057-awaitAll_iterator_next_exception.phpt b/tests/await/057-awaitAllOrFail_iterator_next_exception.phpt similarity index 88% rename from tests/await/057-awaitAll_iterator_next_exception.phpt rename to tests/await/057-awaitAllOrFail_iterator_next_exception.phpt index 20c043f..d234826 100644 --- a/tests/await/057-awaitAll_iterator_next_exception.phpt +++ b/tests/await/057-awaitAllOrFail_iterator_next_exception.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAll() - Exception in iterator next() should stop process immediately +awaitAllOrFail() - Exception in iterator next() should stop process immediately --FILE-- getMessage() . "\n"; diff --git a/tests/await/058-awaitAny_iterator_valid_exception.phpt b/tests/await/058-awaitAnyOrFail_iterator_valid_exception.phpt similarity index 89% rename from tests/await/058-awaitAny_iterator_valid_exception.phpt rename to tests/await/058-awaitAnyOrFail_iterator_valid_exception.phpt index 8476a53..9fc44d7 100644 --- a/tests/await/058-awaitAny_iterator_valid_exception.phpt +++ b/tests/await/058-awaitAnyOrFail_iterator_valid_exception.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAny() - Exception in iterator valid() should stop process immediately +awaitAnyOrFail() - Exception in iterator valid() should stop process immediately --FILE-- getMessage() . "\n"; diff --git a/tests/await/059-awaitAll-with-duplicates.phpt b/tests/await/059-awaitAllOrFail-with-duplicates.phpt similarity index 90% rename from tests/await/059-awaitAll-with-duplicates.phpt rename to tests/await/059-awaitAllOrFail-with-duplicates.phpt index 71c8982..272b6b6 100644 --- a/tests/await/059-awaitAll-with-duplicates.phpt +++ b/tests/await/059-awaitAllOrFail-with-duplicates.phpt @@ -1,10 +1,10 @@ --TEST-- -awaitAll() - with duplicates +awaitAllOrFail() - with duplicates --FILE-- getMessage() . "\n"; } diff --git a/tests/await/060-await_empty_iterable_edge_cases.phpt b/tests/await/060-await_empty_iterable_edge_cases.phpt index 1c2a906..3fd9b9d 100644 --- a/tests/await/060-await_empty_iterable_edge_cases.phpt +++ b/tests/await/060-await_empty_iterable_edge_cases.phpt @@ -9,14 +9,14 @@ echo "start\n"; // Test EmptyIterator $emptyIterator = new EmptyIterator(); -$result1 = awaitAll($emptyIterator); -echo "EmptyIterator count: " . count($result1) . "\n"; -echo "EmptyIterator type: " . gettype($result1) . "\n"; +[$results1, $exceptions1] = awaitAll($emptyIterator); +echo "EmptyIterator count: " . count($results1) . "\n"; +echo "EmptyIterator type: " . gettype($results1) . "\n"; // Test empty SplFixedArray $emptyFixedArray = new SplFixedArray(0); -$result2 = awaitAll($emptyFixedArray); -echo "Empty SplFixedArray count: " . count($result2) . "\n"; +[$results2, $exceptions2] = awaitAll($emptyFixedArray); +echo "Empty SplFixedArray count: " . count($results2) . "\n"; // Test custom empty iterator class CustomEmptyIterator implements Iterator @@ -28,8 +28,8 @@ class CustomEmptyIterator implements Iterator public function valid(): bool { return false; } } -$result3 = awaitAll(new CustomEmptyIterator()); -echo "CustomEmptyIterator count: " . count($result3) . "\n"; +[$results3, $exceptions3] = awaitAll(new CustomEmptyIterator()); +echo "CustomEmptyIterator count: " . count($results3) . "\n"; echo "end\n"; diff --git a/tests/bailout/010-memory-exhaustion-during-awaitAll.phpt b/tests/bailout/010-memory-exhaustion-during-awaitAllOrFail.phpt similarity index 80% rename from tests/bailout/010-memory-exhaustion-during-awaitAll.phpt rename to tests/bailout/010-memory-exhaustion-during-awaitAllOrFail.phpt index 9c9cf9b..84072ef 100644 --- a/tests/bailout/010-memory-exhaustion-during-awaitAll.phpt +++ b/tests/bailout/010-memory-exhaustion-during-awaitAllOrFail.phpt @@ -1,5 +1,5 @@ --TEST-- -Memory exhaustion bailout during awaitAll operation +Memory exhaustion bailout during awaitAllOrFail operation --SKIPIF-- --EXPECTF-- Before spawn -Before awaitAll +Before awaitAllOrFail Coroutine 1 started Coroutine 2 started diff --git a/tests/curl/002-concurrent_requests.phpt b/tests/curl/002-concurrent_requests.phpt index f5f5a70..f48e0c1 100644 --- a/tests/curl/002-concurrent_requests.phpt +++ b/tests/curl/002-concurrent_requests.phpt @@ -41,7 +41,7 @@ $coroutines = [ spawn(fn() => make_request(3, $server)), ]; -$results = awaitAll($coroutines); +[$results, $exceptions] = awaitAll($coroutines); // Collect and sort messages $start_messages = []; diff --git a/tests/curl/009-curl_with_coroutines.phpt b/tests/curl/009-curl_with_coroutines.phpt index 7984cd3..4e9074b 100644 --- a/tests/curl/009-curl_with_coroutines.phpt +++ b/tests/curl/009-curl_with_coroutines.phpt @@ -41,7 +41,7 @@ $coroutines = [ spawn(fn() => make_curl_request($server, 3)) ]; -$results = awaitAll($coroutines); +[$results, $exceptions] = awaitAll($coroutines); // Collect and sort messages $start_messages = []; diff --git a/tests/dns/004-concurrent_dns_lookups.phpt b/tests/dns/004-concurrent_dns_lookups.phpt index 6999a12..9793c97 100644 --- a/tests/dns/004-concurrent_dns_lookups.phpt +++ b/tests/dns/004-concurrent_dns_lookups.phpt @@ -29,7 +29,7 @@ for ($i = 5; $i < 8; $i++) { }); } -$results = awaitAll($coroutines); +[$results, $exceptions] = awaitAll($coroutines); echo "All DNS lookups completed\n"; echo "Total results: " . count($results) . "\n"; diff --git a/tests/dns/009-dns_memory_stress.phpt b/tests/dns/009-dns_memory_stress.phpt index 909bc4a..c8ad972 100644 --- a/tests/dns/009-dns_memory_stress.phpt +++ b/tests/dns/009-dns_memory_stress.phpt @@ -31,7 +31,7 @@ for ($i = 0; $i < $lookup_count; $i++) { }); } -$results = awaitAll($coroutines); +[$results, $exceptions] = awaitAll($coroutines); $end_memory = memory_get_usage(); echo "Ending memory usage: " . number_format($end_memory) . " bytes\n"; diff --git a/tests/edge_cases/006-scheduler_graceful_shutdown_exceptions.phpt b/tests/edge_cases/006-scheduler_graceful_shutdown_exceptions.phpt index fce0edb..45fe2dd 100644 --- a/tests/edge_cases/006-scheduler_graceful_shutdown_exceptions.phpt +++ b/tests/edge_cases/006-scheduler_graceful_shutdown_exceptions.phpt @@ -6,7 +6,7 @@ Scheduler: graceful shutdown with exception handling use function Async\spawn; use function Async\gracefulShutdown; use function Async\suspend; -use function Async\awaitAllWithErrors; +use function Async\awaitAll; echo "start\n"; @@ -30,7 +30,7 @@ echo "coroutines spawned\n"; try { $cancellation = new \Async\CancellationException("Custom shutdown message"); gracefulShutdown($cancellation); - awaitAllWithErrors([$error_coroutine, $cleanup_coroutine]); + awaitAll([$error_coroutine, $cleanup_coroutine]); echo "graceful shutdown with custom cancellation completed\n"; } catch (\Async\CancellationException $e) { echo "caught shutdown cancellation: " . $e->getMessage() . "\n"; diff --git a/tests/info/002-info_getCoroutines_integration.phpt b/tests/info/002-info_getCoroutines_integration.phpt index afef3a6..19259c2 100644 --- a/tests/info/002-info_getCoroutines_integration.phpt +++ b/tests/info/002-info_getCoroutines_integration.phpt @@ -8,7 +8,6 @@ use function Async\getCoroutines; use function Async\currentCoroutine; use function Async\suspend; use function Async\awaitAll; -use function Async\awaitAllWithErrors; echo "start\n"; @@ -56,12 +55,12 @@ foreach ($coroutines as $index => $coroutine) { echo "Coroutine {$index} is isCancellationRequested: " . ($coroutine->isCancellationRequested() ? "true" : "false") . "\n"; } -$results = awaitAllWithErrors($coroutines); // Ensure we yield to allow cancellation to take effect +[$results, $exceptions] = awaitAll($coroutines); // Ensure we yield to allow cancellation to take effect $after_partial_cancel = count(getCoroutines()) - $initial_count; echo "After cancelling 2: {$after_partial_cancel}\n"; -echo "Completed results: " . count($results[0]) . "\n"; +echo "Completed results: " . count($results) . "\n"; $final_count = count(getCoroutines()) - $initial_count; echo "Final count: {$final_count}\n"; diff --git a/tests/stream/007-tcp_client_server_full.phpt b/tests/stream/007-tcp_client_server_full.phpt index 68b79ac..900c2c1 100644 --- a/tests/stream/007-tcp_client_server_full.phpt +++ b/tests/stream/007-tcp_client_server_full.phpt @@ -72,7 +72,7 @@ $worker = spawn(function() { return "worker_done"; }); -$results = awaitAll([$server, $client, $worker]); +[$results, $exceptions] = awaitAll([$server, $client, $worker]); echo "Results: " . implode(", ", $results) . "\n"; echo "End\n"; diff --git a/tests/stream/009-multiple_coroutines_sockets.phpt b/tests/stream/009-multiple_coroutines_sockets.phpt index 5a77cf1..ddff2b9 100644 --- a/tests/stream/009-multiple_coroutines_sockets.phpt +++ b/tests/stream/009-multiple_coroutines_sockets.phpt @@ -42,7 +42,7 @@ for ($i = 1; $i <= 3; $i++) { }); } -$results = awaitAll($coroutines); +[$results, $exceptions] = awaitAll($coroutines); foreach ($results as $i => $result) { echo "Result " . ($i + 1) . ": $result\n"; }