Coroutine::isStarted

(PHP 8.6+, True Async 1.0)

public Coroutine::isStarted(): bool

Prueft, ob die Coroutine vom Scheduler gestartet wurde. Eine Coroutine gilt als gestartet, nachdem der Scheduler ihre Ausfuehrung begonnen hat.

Rueckgabewert

booltrue, wenn die Coroutine gestartet wurde.

Beispiele

Beispiel #1 Vor und nach dem Start pruefen

<?php

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

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

var_dump($coroutine->isStarted()); // bool(false) -- noch in der Warteschlange

suspend(); // Scheduler die Coroutine starten lassen

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

await($coroutine);

var_dump($coroutine->isStarted()); // bool(true) -- nach dem Abschluss immer noch true

Siehe auch