>  There should be no perceptible difference between a blocking sleep(10)
and an async sleep(10), so what backwards compatibility are you referring
to?

For example, the behavior of the code below will not change. The code will
execute sequentially, and context switching will only occur when resume/
suspend is called.

However, when the Scheduler is activated, this behavior changes. Now,
calling sleep() inside a Fiber will lead to a context switch.

If the activation of the Scheduler is implicit, previously written code may
not work as the developer expects.

<?php

$fiber = new Fiber(function (): void {
    echo "Start fiber\n";
    sleep(1);
    Fiber::suspend("Paused");
    echo "Resume fiber\n";
});

$result = $fiber->start();

echo "Fiber suspended with: $result\n";

sleep(10);

$fiber->resume();

echo "Fiber finished\n";

Reply via email to