123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::ConnectionAdapters::ConnectionPool::LeaseRegistry

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ::ActiveSupport::WeakKeyMap, ObjectSpace::WeakKeyMap
Instance Chain:
self, ::ActiveSupport::WeakKeyMap, ObjectSpace::WeakKeyMap
Inherits: ActiveSupport::WeakKeyMap
Defined in: activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb

Class Method Summary

Instance Method Summary

::ActiveSupport::WeakKeyMap - Inherited

#[], #[]=, #clear, #delete,
#fetch_or_store

Returns the cached value, computing and storing it when nil.

Constructor Details

.new ⇒ LeaseRegistry

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb', line 208

def initialize
  super()
  @terminated_flag = Concurrent::AtomicBoolean.new(false)
  @lease_mutex = Mutex.new
end

Instance Method Details

#clear

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb', line 222

def clear
  @lease_mutex.synchronize do
    result = super
    old_flag = @terminated_flag
    @terminated_flag = Concurrent::AtomicBoolean.new(false)
    old_flag.make_true
    result
  end
end

#lease(context)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb', line 214

def lease(context)
  @lease_mutex.synchronize do
    fetch_or_store(context) do
      Lease.new(@terminated_flag)
    end
  end
end