123456789_123456789_123456789_123456789_123456789_

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

Do not use. This class is for internal use only.

Overview

Thanks to the GVL, the LeaseRegistry doesn’t need to be synchronized on MRI

Class Method Summary

WeakThreadKeyMap - Inherited

.new

FIXME: On 3.3 we could use ObjectSpace::WeakKeyMap but it currently causes GC crashes: github.com/byroot/rails/pull/3.

Instance Method Summary

WeakThreadKeyMap - Inherited

Constructor Details

.newLeaseRegistry

[ GitHub ]

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

def initialize
  @mutex = Mutex.new
  @map = WeakThreadKeyMap.new
end

Instance Method Details

#[](context)

See additional method definition at line 186.

[ GitHub ]

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

def [](context)
  super || (self[context] = Lease.new)
end

#clear

[ GitHub ]

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

def clear
  @mutex.synchronize do
    @map.clear
  end
end