Scope::isFinished
(PHP 8.6+, True Async 1.0)
php
public function isFinished(): boolChecks 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
bool — true if all scope coroutines have finished, false otherwise.
Examples
Example #1 Checking scope completion
php
<?php
use Async\Scope;
$scope = new Scope();
$scope->spawn(function() {
\Async\delay(1000);
});
var_dump($scope->isFinished()); // bool(false)
$scope->awaitCompletion(Async\timeout(5000));
var_dump($scope->isFinished()); // bool(true)See Also
- Scope::isClosed — Check if the scope is closed
- Scope::isCancelled — Check if the scope is cancelled
- Scope::awaitCompletion — Wait for coroutine completion