Coroutine::isStarted

(PHP 8.6+, True Async 1.0)

public Coroutine::isStarted(): bool

Vérifie si la coroutine a été démarrée par l’ordonnanceur. Une coroutine est considérée comme démarrée après que l’ordonnanceur a commencé son exécution.

Valeur de retour

booltrue si la coroutine a été démarrée.

Exemples

Exemple #1 Vérification avant et après le démarrage

<?php

use function Async\spawn;
use function Async\suspend;
use function Async\await;

$coroutine = spawn(function() {
    return "test";
});

var_dump($coroutine->isStarted()); // bool(false) -- encore dans la file

suspend(); // laisser l'ordonnanceur démarrer la coroutine

var_dump($coroutine->isStarted()); // bool(true)

await($coroutine);

var_dump($coroutine->isStarted()); // bool(true) -- toujours true après la terminaison

Voir aussi