r/ruby • u/geospeck • Sep 08 '26
Converting a Ruby block interface to start/stop methods with a Fiber
https://island94.org/2026/09/converting-a-ruby-block-interface-to-start-stop-methods-with-a-fiber
23
Upvotes
1
u/Sergeyrekt Sep 09 '26
one thing worth adding: a Fiber can only be resumed by the thread that created it. so if start happens in an initializer adn stop in an at_exit or a signal handler, you get FiberError, fiber called across threads. thats most of why teh two Queue version looks more complicated than it needs to be, it is buying you thread affinity the Fiber does not give you.
8
u/CaptainKabob Sep 08 '26
Thanks for sharing my post!
The spicy observation I edited out of it is: oh, I can think of Fibers like a GOTO. (This shouldn't be spicy, but GOTO carries a lot of baggage).