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, ObjectSpace::WeakKeyMap
Instance Chain:
self, ObjectSpace::WeakKeyMap
Inherits: ObjectSpace::WeakKeyMap
Defined in: activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb,
activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb

Overview

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

Class Method Summary

Instance Method Summary

Constructor Details

.new ⇒ LeaseRegistry

[ GitHub ]

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

def initialize
  @mutex = Mutex.new
  @map = ObjectSpace::WeakKeyMap.new
end

Instance Method Details

#[](context)

See additional method definition at line 164.

[ GitHub ]

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

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

#clear

[ GitHub ]

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

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