diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-30 15:19:07 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-30 15:19:07 -0800 |
commit | cde7692d4e3e0e67e480cc6172f6e2bacaceeb5e (patch) | |
tree | 8b31ee31bee1cebc067174fc7355ea1f0b503708 /activerecord/lib | |
parent | cceabe03a80c4a0121a2b1187b56a2d29586a43b (diff) | |
download | rails-cde7692d4e3e0e67e480cc6172f6e2bacaceeb5e.tar.gz rails-cde7692d4e3e0e67e480cc6172f6e2bacaceeb5e.tar.bz2 rails-cde7692d4e3e0e67e480cc6172f6e2bacaceeb5e.zip |
introduce a timer class for reaping connections
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb index 124875d52f..a26c435dad 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -64,6 +64,25 @@ module ActiveRecord # * +wait_timeout+: number of seconds to block and wait for a connection # before giving up and raising a timeout error (default 5 seconds). class ConnectionPool + class Reaper + attr_reader :pool, :frequency + + def initialize(pool, frequency) + @pool = pool + @frequency = frequency + end + + def start + return unless frequency + Thread.new(frequency, pool) { |t, p| + while true + sleep t + p.reap + end + } + end + end + include MonitorMixin attr_accessor :automatic_reconnect, :timeout |