@@ -249,12 +249,14 @@ PHP_FUNCTION(Async_awaitAny)
249249 Z_PARAM_OBJ_OF_CLASS_OR_NULL (cancellation , async_ce_awaitable );
250250 ZEND_PARSE_PARAMETERS_END ();
251251
252+ SCHEDULER_LAUNCH ;
253+
252254 HashTable * results = zend_new_array (8 );
253255
254256 async_await_futures (futures ,
255257 1 ,
256258 false,
257- ZEND_ASYNC_OBJECT_TO_EVENT (cancellation ),
259+ cancellation != NULL ? ZEND_ASYNC_OBJECT_TO_EVENT (cancellation ) : NULL ,
258260 0 ,
259261 0 ,
260262 results ,
@@ -273,7 +275,11 @@ PHP_FUNCTION(Async_awaitAny)
273275 }
274276
275277 zval result ;
276- ZVAL_COPY (& result , zend_hash_index_find (results , 0 ));
278+ ZEND_HASH_FOREACH_VAL (results , zval * item ) {
279+ ZVAL_COPY (& result , item );
280+ break ;
281+ } ZEND_HASH_FOREACH_END ();
282+
277283 zend_array_release (results );
278284
279285 RETURN_ZVAL (& result , 0 , 0 );
@@ -290,13 +296,15 @@ PHP_FUNCTION(Async_awaitFirstSuccess)
290296 Z_PARAM_OBJ_OF_CLASS_OR_NULL (cancellation , async_ce_awaitable );
291297 ZEND_PARSE_PARAMETERS_END ();
292298
299+ SCHEDULER_LAUNCH ;
300+
293301 HashTable * results = zend_new_array (8 );
294302 HashTable * errors = zend_new_array (8 );
295303
296304 async_await_futures (futures ,
297305 1 ,
298306 true,
299- ZEND_ASYNC_OBJECT_TO_EVENT (cancellation ),
307+ cancellation != NULL ? ZEND_ASYNC_OBJECT_TO_EVENT (cancellation ) : NULL ,
300308 0 ,
301309 0 ,
302310 results ,
@@ -339,12 +347,14 @@ PHP_FUNCTION(Async_awaitAll)
339347 Z_PARAM_OBJ_OF_CLASS_OR_NULL (cancellation , async_ce_awaitable );
340348 ZEND_PARSE_PARAMETERS_END ();
341349
350+ SCHEDULER_LAUNCH ;
351+
342352 HashTable * results = zend_new_array (8 );
343353
344354 async_await_futures (futures ,
345355 0 ,
346356 false,
347- ZEND_ASYNC_OBJECT_TO_EVENT (cancellation ),
357+ cancellation != NULL ? ZEND_ASYNC_OBJECT_TO_EVENT (cancellation ) : NULL ,
348358 0 ,
349359 0 ,
350360 results ,
@@ -371,13 +381,15 @@ PHP_FUNCTION(Async_awaitAllWithErrors)
371381 Z_PARAM_OBJ_OF_CLASS_OR_NULL (cancellation , async_ce_awaitable );
372382 ZEND_PARSE_PARAMETERS_END ();
373383
384+ SCHEDULER_LAUNCH ;
385+
374386 HashTable * results = zend_new_array (8 );
375387 HashTable * errors = zend_new_array (8 );
376388
377389 async_await_futures (futures ,
378390 0 ,
379391 true,
380- ZEND_ASYNC_OBJECT_TO_EVENT (cancellation ),
392+ cancellation != NULL ? ZEND_ASYNC_OBJECT_TO_EVENT (cancellation ) : NULL ,
381393 0 ,
382394 0 ,
383395 results ,
@@ -416,12 +428,14 @@ PHP_FUNCTION(Async_awaitAnyOf)
416428 Z_PARAM_OBJ_OF_CLASS_OR_NULL (cancellation , async_ce_awaitable );
417429 ZEND_PARSE_PARAMETERS_END ();
418430
431+ SCHEDULER_LAUNCH ;
432+
419433 HashTable * results = zend_new_array (8 );
420434
421435 async_await_futures (futures ,
422436 (int )count ,
423437 false,
424- ZEND_ASYNC_OBJECT_TO_EVENT (cancellation ),
438+ cancellation != NULL ? ZEND_ASYNC_OBJECT_TO_EVENT (cancellation ) : NULL ,
425439 0 ,
426440 0 ,
427441 results ,
@@ -453,10 +467,12 @@ PHP_FUNCTION(Async_awaitAnyOfWithErrors)
453467 HashTable * results = zend_new_array (8 );
454468 HashTable * errors = zend_new_array (8 );
455469
470+ SCHEDULER_LAUNCH ;
471+
456472 async_await_futures (futures ,
457473 (int )count ,
458474 true,
459- ZEND_ASYNC_OBJECT_TO_EVENT (cancellation ),
475+ cancellation != NULL ? ZEND_ASYNC_OBJECT_TO_EVENT (cancellation ) : NULL ,
460476 0 ,
461477 0 ,
462478 results ,
@@ -490,6 +506,8 @@ PHP_FUNCTION(Async_delay)
490506 Z_PARAM_LONG (ms )
491507 ZEND_PARSE_PARAMETERS_END ();
492508
509+ SCHEDULER_LAUNCH ;
510+
493511 zend_coroutine_t * coroutine = ZEND_ASYNC_CURRENT_COROUTINE ;
494512
495513 if (UNEXPECTED (coroutine == NULL )) {
0 commit comments