2 ms·
PHP Fibers does not do anything on its own. Its basically just syntax for generators, to be used with various external runtimes. This means in a vanilla PHP se
by phplovesong 1y ago
PHP Fibers does not do anything on its own. Its basically just syntax for generators, to be used with various external runtimes.
This means in a vanilla PHP setup when i do something like this:
$a = new Fiber(function () {
sleep(2); // block
Fiber::suspend();
return null;
});
$b = new Fiber(function () {
sleep(2); // block
Fiber::suspend();
return null;
});
// Start execution
$a->start();
$b->start();
// ... later in code wait for both executions to finish
$a->resume();
$b->resume();
// Total execution time is not 2 seconds, but 4
I need an additional runtime to support real concurrency. I also need a separate async IO library to handle blocking. This is usually a showstopper for most PHP still out there. And just annoying on so many levels.