4 ms·
How do the fibers being introduced in PHP 8.1 compare with Ruby's? https://php.watch/versions/8.1/fibers https://php.watch/versions/8.1/fibers
by g8oz 5y ago
How do the fibers being introduced in PHP 8.1 compare with Ruby's?
https://php.watch/versions/8.1/fibers https://php.watch/versions/8.1/fibers
- matheusmoreira 5y agoLooks like they work the same way. The documentation talks about the same concepts: cooperatively-scheduled tasks implemented in the virtual machine with small stacks that support concurrency, don't run code in parallel and may perform I/O asynchronously in parallel given operating system support. Implementation details will vary.
- pansa2 5y agoPHP’s fibers seem to be purely asymmetric - they provide only `resume(fiber)` and `suspend()` functions. Lua’s coroutines are similar. OTOH Ruby’s fibers also provide a symmetric `transfer(fiber)` function. Asymmetric and symmetric coroutines are equivalent, so presumably Ruby implements one in terms of the other - it would be interesting to find out exactly how that was done.