ComponentiScope::isFinished

Scope::isFinished ​

(PHP 8.6+, True Async 1.0)

php
public function isFinished(): bool

Verifica se tutte le coroutine nello scope sono terminate. Uno scope e' considerato terminato quando tutte le sue coroutine (inclusi gli scope figli) hanno completato l'esecuzione.

Valore di ritorno ​

bool — true se tutte le coroutine dello scope sono terminate, false altrimenti.

Esempi ​

Esempio #1 Verifica del completamento dello scope ​

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)

Vedi anche ​