diff options
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 75e568b557..4a9653c08c 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -4,6 +4,7 @@ require 'bigdecimal/util' require 'active_support/core_ext/benchmark' require 'active_support/deprecation' require 'active_record/connection_adapters/schema_cache' +require 'monitor' module ActiveRecord module ConnectionAdapters # :nodoc: @@ -48,13 +49,17 @@ module ActiveRecord include DatabaseLimits include QueryCache include ActiveSupport::Callbacks + include MonitorMixin define_callbacks :checkout, :checkin attr_accessor :visitor - attr_reader :schema_cache + attr_reader :schema_cache, :last_use, :in_use + alias :in_use? :in_use def initialize(connection, logger = nil) #:nodoc: + super() + @active = nil @connection, @logger = connection, logger @query_cache_enabled = false @@ -63,6 +68,14 @@ module ActiveRecord @instrumenter = ActiveSupport::Notifications.instrumenter @visitor = nil @schema_cache = SchemaCache.new self + @in_use = false + end + + def lease + synchronize do + @in_use = true + @last_use = Time.now + end end # Returns the human-readable name of the adapter. Use mixed case - one |