Search⌘ K
AI Features

... continued

Explore the use of Fiber.yield in Ruby to control execution flow in asynchronous programming. Understand how fibers return control and values, receive inputs, and differ from traditional method calls. This lesson helps you grasp advanced concurrency techniques to improve resource management and web server performance.

We'll cover the following...

Yielding from Fibers

In the previous lesson, we used fibers much like function calls but the true potential of fibers is truly unleashed, when used with Fiber.yield. Don't confuse Fiber.yield with yield, the latter is used to execute arbitrary blocks of code. The Fiber.yield serves two purposes:

  • Returns control back to the invoker of the resume() method on the fiber.

  • Return a value to the invoker. ...