an_iterator
in a fiber, and passes a block which suspends the fiber. So every time an_iterator
yields to the block, the fiber which it is running on is suspended, and execution continues on the main thread. Next time you call next
, it passes control to the fiber, the block returns, and an_iterator
continues where it left off.