4 ms·
Explaining Ruby Fibers
- sizediterable 5y agoDoes anyone know of if the issues brought up by njs in this thread still apply? https://trio.discourse.group/t/structured-concurrency-in-ruby/314/10 https://trio.discourse.group/t/structured-concurrency-in-rub...
- burlesona 5y agoThis was a great read, but even more interesting was all the work on the author’s GitHub: https://github.com/digital-fabric https://github.com/digital-fabric Sharon is essentially developing a whole new stack of Ruby core libraries updated to feel more 2021 web than 2006 web (but in a good way). There’s a lot of neat stuff here to explore.
- sizediterable 5y agoAn algebraic effects library: https://github.com/digital-fabric/affect https://github.com/digital-fabric/affect He has great taste!
- ciconia 5y agoI'm a he. No offense taken, thanks for the kind words!
- sizediterable 5y agoFixed, my apologies
- ksec 5y agoI think it is unfortunate that whole stack gets zero attention.
- g8oz 5y agoHow 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.
- c-smile 5y agoJust for the note, in JS these two: async function foo() {...} function* bar() {...} // a.k.a. generator are fibers. These are execution contexts that JS VM can be switched into. The first one (asynchronous function) uses kind-of preemptive multitasking (implicit context switch) and generators are closer to canonical fibers - cooperative multitasking with explicit yield of VM to other fibers.
- pansa2 5y agoAsync functions and generators, in both JavaScript and Python, are forms of (asymmetric) stackless coroutines. Usually the term “fiber” is only used for stackful coroutines.
- fzzzy 5y agoFibers are symmetrical coroutines, generators and async functions are asymmetrical coroutines. They are slightly different.
- allenrb 5y agoHave to admit, clicked on this expecting to learn about some sort of exotic optical fiber.
- sharmin123 5y agoAre There Top Signs of a Cheating Lover? What To do Then?: https://www.hackerslist.co/are-there-top-signs-of-a-cheating-lover-what-to-do-then/ https://www.hackerslist.co/are-there-top-signs-of-a-cheating...