From 40c22b3f0a2ace6e4b51a39624ac5ed5ee3d0162 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 27 Dec 2010 03:56:30 +0000 Subject: fiber/*: more efficient keepalive_timeout expiry We can use the same interface as Rainbows::Fiber.sleep to avoid blindly waking up readers at ever scheduler invocation. --- lib/rainbows/fiber/io/methods.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/rainbows/fiber/io') diff --git a/lib/rainbows/fiber/io/methods.rb b/lib/rainbows/fiber/io/methods.rb index 6c4d44d..29c9854 100644 --- a/lib/rainbows/fiber/io/methods.rb +++ b/lib/rainbows/fiber/io/methods.rb @@ -8,8 +8,13 @@ module Rainbows::Fiber::IO::Methods RD = Rainbows::Fiber::RD WR = Rainbows::Fiber::WR + ZZ = Rainbows::Fiber::ZZ attr_accessor :f + def read_expire + ZZ[Fiber.current] = super + end + # for wrapping output response bodies def each(&block) if buf = kgio_read(16384) @@ -30,6 +35,7 @@ module Rainbows::Fiber::IO::Methods @f = Fiber.current RD[fd] = self Fiber.yield + ZZ.delete @f RD[fd] = nil end -- cgit v1.2.3-24-ge0c7