一小段代码理解Fiber 博客分类: RubyFiber rubyfiber
程序员文章站
2024-02-12 15:12:34
...
server = Fiber.new do |request| puts 'Server Started' while(request != 'exit') puts "Received request: #{request}" request = Fiber.yield Random.rand end end response = server.resume 'hi' puts response response = server.resume 'hello' puts response response = server.resume 'exit' puts response server.resume '???'