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

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/abstract/connection_pool.rb

Overview

:nodoc:

Defined Under Namespace

Classes: WeakKeyMap

Instance Method Summary collapse

Constructor Details

#initializeLeaseRegistry

Returns a new instance of LeaseRegistry.



187
188
189
190
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 187

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

Instance Method Details

#[](context) ⇒ Object



192
193
194
195
196
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 192

def [](context)
  @mutex.synchronize do
    @map[context] ||= Lease.new
  end
end

#clearObject



198
199
200
201
202
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 198

def clear
  @mutex.synchronize do
    @map = WeakKeyMap.new
  end
end