Scope::isFinished

(PHP 8.6+, True Async 1.0)

public function isFinished(): bool

Checks whether all coroutines in the scope have finished. A scope is considered finished when all its coroutines (including child scopes) have completed execution.

Return Value

booltrue if all scope coroutines have finished, false otherwise.

Examples

Example #1 Checking scope completion

<?php

use Async\Scope;

$scope = new Scope();

$scope->spawn(function() {
    \Async\delay(1000);
});

var_dump($scope->isFinished()); // bool(false)

$scope->awaitCompletion();

var_dump($scope->isFinished()); // bool(true)

See Also