rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob 056b6eff80c40acff67b351ba0d6cc79331ee618 363 bytes (raw)
$ git show v1.0.0pre1:lib/rainbows/fiber/rev/kato.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
# -*- encoding: binary -*-
# :enddoc:
# keep-alive timeout class
class Rainbows::Fiber::Rev::Kato < Rev::TimerWatcher
  def initialize
    @watch = []
    super(1, true)
  end

  def <<(fiber)
    @watch << fiber
    enable unless enabled?
  end

  def on_timer
    @watch.uniq!
    while f = @watch.shift
      f.resume if f.alive?
    end
    disable
  end
end

git clone https://yhbt.net/rainbows.git