From 40445641f11f01c6a24bf96c8b80eed5fd33a512 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 28 Dec 2010 17:59:27 -0800 Subject: complete Rev => Coolio renaming We use Cool.io internally everywhere now, but preserve Rev-based models for anybody using them. --- lib/rainbows/coolio/heartbeat.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lib/rainbows/coolio/heartbeat.rb (limited to 'lib/rainbows/coolio/heartbeat.rb') diff --git a/lib/rainbows/coolio/heartbeat.rb b/lib/rainbows/coolio/heartbeat.rb new file mode 100644 index 0000000..d1f4747 --- /dev/null +++ b/lib/rainbows/coolio/heartbeat.rb @@ -0,0 +1,20 @@ +# -*- encoding: binary -*- +# :enddoc: +# This class handles the Unicorn fchmod heartbeat mechanism +# in Coolio-based concurrency models to prevent the master +# process from killing us unless we're blocked. This class +# will also detect and execute the graceful exit if triggered +# by SIGQUIT +class Rainbows::Coolio::Heartbeat < Coolio::TimerWatcher + KATO = Rainbows::Coolio::KATO + CONN = Rainbows::Coolio::CONN + G = Rainbows::G + + def on_timer + if (ot = G.kato) >= 0 + ot = Time.now - ot + KATO.delete_if { |client, time| time < ot and client.timeout? } + end + exit if (! G.tick && CONN.size <= 0) + end +end -- cgit v1.2.3-24-ge0c7