trace_location 0.9.3 → 0.9.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2279 @@
1
+ Generated by [trace_location](https://github.com/yhirano55/trace_location) at 2019-06-08 01:09:55 +0900
2
+
3
+ <details open>
4
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:49</summary>
5
+
6
+ ##### ActiveRecord::ConnectionHandling.establish_connection
7
+
8
+ ```ruby
9
+ def establish_connection(config = nil)
10
+ raise "Anonymous class is not allowed." unless name
11
+
12
+ config ||= DEFAULT_ENV.call.to_sym
13
+ spec_name = self == Base ? "primary" : name
14
+ self.connection_specification_name = spec_name
15
+
16
+ resolver = ConnectionAdapters::ConnectionSpecification::Resolver.new(Base.configurations)
17
+ spec = resolver.resolve(config).symbolize_keys
18
+ spec[:name] = spec_name
19
+
20
+ connection_handler.establish_connection(spec)
21
+ end
22
+ # called from (irb):4
23
+ ```
24
+ </details>
25
+ <details open>
26
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/core.rb:59</summary>
27
+
28
+ ##### ActiveRecord::Base.configurations
29
+
30
+ ```ruby
31
+ def self.configurations
32
+ @@configurations
33
+ end
34
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:56
35
+ ```
36
+ </details>
37
+ <details open>
38
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:121</summary>
39
+
40
+ ##### ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver#initialize
41
+
42
+ ```ruby
43
+ def initialize(configurations)
44
+ @configurations = configurations
45
+ end
46
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:56
47
+ ```
48
+ </details>
49
+ <details open>
50
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:141</summary>
51
+
52
+ ##### ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver#resolve
53
+
54
+ ```ruby
55
+ def resolve(config)
56
+ if config
57
+ resolve_connection config
58
+ elsif env = ActiveRecord::ConnectionHandling::RAILS_ENV.call
59
+ resolve_symbol_connection env.to_sym
60
+ else
61
+ raise AdapterNotSpecified
62
+ end
63
+ end
64
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:57
65
+ ```
66
+ </details>
67
+ <details open>
68
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:238</summary>
69
+
70
+ ##### ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver#resolve_connection
71
+
72
+ ```ruby
73
+ def resolve_connection(spec)
74
+ case spec
75
+ when Symbol
76
+ resolve_symbol_connection spec
77
+ when String
78
+ resolve_url_connection spec
79
+ when Hash
80
+ resolve_hash_connection spec
81
+ end
82
+ end
83
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:143
84
+ ```
85
+ </details>
86
+ <details open>
87
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:268</summary>
88
+
89
+ ##### ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver#resolve_hash_connection
90
+
91
+ ```ruby
92
+ def resolve_hash_connection(spec)
93
+ if spec["url"] && spec["url"] !~ /^jdbc:/
94
+ connection_hash = resolve_url_connection(spec.delete("url"))
95
+ spec.merge!(connection_hash)
96
+ end
97
+ spec
98
+ end
99
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:245
100
+ ```
101
+ </details>
102
+ <details open>
103
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/core_ext/hash/keys.rb:56</summary>
104
+
105
+ ##### Hash#symbolize_keys
106
+
107
+ ```ruby
108
+ def symbolize_keys
109
+ transform_keys { |key| key.to_sym rescue key }
110
+ end
111
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:57
112
+ ```
113
+ </details>
114
+ <details open>
115
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/core.rb:130</summary>
116
+
117
+ ##### ActiveRecord::Base.connection_handler
118
+
119
+ ```ruby
120
+ def self.connection_handler
121
+ ActiveRecord::RuntimeRegistry.connection_handler || default_connection_handler
122
+ end
123
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:60
124
+ ```
125
+ </details>
126
+ <details open>
127
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/runtime_registry.rb:20</summary>
128
+
129
+ ##### ActiveRecord::RuntimeRegistry.connection_handler
130
+
131
+ ```ruby
132
+ class_eval %{ def self.#{val}; instance.#{val}; end }, __FILE__, __LINE__
133
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/core.rb:131
134
+ ```
135
+ </details>
136
+ <details open>
137
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/per_thread_registry.rb:46</summary>
138
+
139
+ ##### ActiveSupport::PerThreadRegistry.instance
140
+
141
+ ```ruby
142
+ def instance
143
+ Thread.current[@per_thread_registry_key] ||= new
144
+ end
145
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/runtime_registry.rb:20
146
+ ```
147
+ </details>
148
+ <details open>
149
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106</summary>
150
+
151
+ ##### ActiveRecord::Base.default_connection_handler
152
+
153
+ ```ruby
154
+ redefine_method(name) { val }
155
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/core.rb:131
156
+ ```
157
+ </details>
158
+ <details open>
159
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:954</summary>
160
+
161
+ ##### ActiveRecord::ConnectionAdapters::ConnectionHandler#establish_connection
162
+
163
+ ```ruby
164
+ def establish_connection(config)
165
+ resolver = ConnectionSpecification::Resolver.new(Base.configurations)
166
+ spec = resolver.spec(config)
167
+
168
+ remove_connection(spec.name)
169
+
170
+ message_bus = ActiveSupport::Notifications.instrumenter
171
+ payload = {
172
+ connection_id: object_id
173
+ }
174
+ if spec
175
+ payload[:spec_name] = spec.name
176
+ payload[:config] = spec.config
177
+ end
178
+
179
+ message_bus.instrument("!connection.active_record", payload) do
180
+ owner_to_pool[spec.name] = ConnectionAdapters::ConnectionPool.new(spec)
181
+ end
182
+
183
+ owner_to_pool[spec.name]
184
+ end
185
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:60
186
+ ```
187
+ </details>
188
+ <details open>
189
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/core.rb:59</summary>
190
+
191
+ ##### ActiveRecord::Base.configurations
192
+
193
+ ```ruby
194
+ def self.configurations
195
+ @@configurations
196
+ end
197
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:955
198
+ ```
199
+ </details>
200
+ <details open>
201
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:121</summary>
202
+
203
+ ##### ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver#initialize
204
+
205
+ ```ruby
206
+ def initialize(configurations)
207
+ @configurations = configurations
208
+ end
209
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:955
210
+ ```
211
+ </details>
212
+ <details open>
213
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:181</summary>
214
+
215
+ ##### ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver#spec
216
+
217
+ ```ruby
218
+ def spec(config)
219
+ spec = resolve(config).symbolize_keys
220
+
221
+ raise(AdapterNotSpecified, "database configuration does not specify adapter") unless spec.key?(:adapter)
222
+
223
+ # Require the adapter itself and give useful feedback about
224
+ # 1. Missing adapter gems and
225
+ # 2. Adapter gems' missing dependencies.
226
+ path_to_adapter = "active_record/connection_adapters/#{spec[:adapter]}_adapter"
227
+ begin
228
+ require path_to_adapter
229
+ rescue LoadError => e
230
+ # We couldn't require the adapter itself. Raise an exception that
231
+ # points out config typos and missing gems.
232
+ if e.path == path_to_adapter
233
+ # We can assume that a non-builtin adapter was specified, so it's
234
+ # either misspelled or missing from Gemfile.
235
+ raise LoadError, "Could not load the '#{spec[:adapter]}' Active Record adapter. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile.", e.backtrace
236
+
237
+ # Bubbled up from the adapter require. Prefix the exception message
238
+ # with some guidance about how to address it and reraise.
239
+ else
240
+ raise LoadError, "Error loading the '#{spec[:adapter]}' Active Record adapter. Missing a gem it depends on? #{e.message}", e.backtrace
241
+ end
242
+ end
243
+
244
+ adapter_method = "#{spec[:adapter]}_connection"
245
+
246
+ unless ActiveRecord::Base.respond_to?(adapter_method)
247
+ raise AdapterNotFound, "database configuration specifies nonexistent #{spec.config[:adapter]} adapter"
248
+ end
249
+
250
+ ConnectionSpecification.new(spec.delete(:name) || "primary", spec, adapter_method)
251
+ end
252
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:956
253
+ ```
254
+ </details>
255
+ <details open>
256
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:141</summary>
257
+
258
+ ##### ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver#resolve
259
+
260
+ ```ruby
261
+ def resolve(config)
262
+ if config
263
+ resolve_connection config
264
+ elsif env = ActiveRecord::ConnectionHandling::RAILS_ENV.call
265
+ resolve_symbol_connection env.to_sym
266
+ else
267
+ raise AdapterNotSpecified
268
+ end
269
+ end
270
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:182
271
+ ```
272
+ </details>
273
+ <details open>
274
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:238</summary>
275
+
276
+ ##### ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver#resolve_connection
277
+
278
+ ```ruby
279
+ def resolve_connection(spec)
280
+ case spec
281
+ when Symbol
282
+ resolve_symbol_connection spec
283
+ when String
284
+ resolve_url_connection spec
285
+ when Hash
286
+ resolve_hash_connection spec
287
+ end
288
+ end
289
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:143
290
+ ```
291
+ </details>
292
+ <details open>
293
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:268</summary>
294
+
295
+ ##### ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver#resolve_hash_connection
296
+
297
+ ```ruby
298
+ def resolve_hash_connection(spec)
299
+ if spec["url"] && spec["url"] !~ /^jdbc:/
300
+ connection_hash = resolve_url_connection(spec.delete("url"))
301
+ spec.merge!(connection_hash)
302
+ end
303
+ spec
304
+ end
305
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:245
306
+ ```
307
+ </details>
308
+ <details open>
309
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/core_ext/hash/keys.rb:56</summary>
310
+
311
+ ##### Hash#symbolize_keys
312
+
313
+ ```ruby
314
+ def symbolize_keys
315
+ transform_keys { |key| key.to_sym rescue key }
316
+ end
317
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:182
318
+ ```
319
+ </details>
320
+ <details open>
321
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:289</summary>
322
+
323
+ ##### ActiveSupport::Dependencies::Loadable#require
324
+
325
+ ```ruby
326
+ def require(file)
327
+ result = false
328
+ load_dependency(file) { result = super }
329
+ result
330
+ end
331
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:191
332
+ ```
333
+ </details>
334
+ <details open>
335
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:251</summary>
336
+
337
+ ##### ActiveSupport::Dependencies::Loadable#load_dependency
338
+
339
+ ```ruby
340
+ def load_dependency(file)
341
+ if Dependencies.load? && Dependencies.constant_watch_stack.watching?
342
+ descs = Dependencies.constant_watch_stack.watching.flatten.uniq
343
+
344
+ Dependencies.new_constants_in(*descs) { yield }
345
+ else
346
+ yield
347
+ end
348
+ rescue Exception => exception # errors from loading file
349
+ exception.blame_file! file if exception.respond_to? :blame_file!
350
+ raise
351
+ end
352
+ # called from vendor/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291
353
+ ```
354
+ </details>
355
+ <details open>
356
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:328</summary>
357
+
358
+ ##### ActiveSupport::Dependencies.load?
359
+
360
+ ```ruby
361
+ def load?
362
+ mechanism == :load
363
+ end
364
+ # called from vendor/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:252
365
+ ```
366
+ </details>
367
+ <details open>
368
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/core_ext/module/attribute_accessors.rb:60</summary>
369
+
370
+ ##### ActiveSupport::Dependencies.mechanism
371
+
372
+ ```ruby
373
+ def self.#{sym}
374
+ @@#{sym}
375
+ end
376
+ # called from vendor/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:329
377
+ ```
378
+ </details>
379
+ <details open>
380
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/core_ext/module/attribute_accessors.rb:60</summary>
381
+
382
+ ##### ActiveSupport::Dependencies.constant_watch_stack
383
+
384
+ ```ruby
385
+ def self.#{sym}
386
+ @@#{sym}
387
+ end
388
+ # called from vendor/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:252
389
+ ```
390
+ </details>
391
+ <details open>
392
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:111</summary>
393
+
394
+ ##### ActiveSupport::Dependencies::WatchStack#watching?
395
+
396
+ ```ruby
397
+ def watching?
398
+ !@watching.empty?
399
+ end
400
+ # called from vendor/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:252
401
+ ```
402
+ </details>
403
+ <details open>
404
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:10</summary>
405
+
406
+ ##### ActiveRecord::ConnectionAdapters::ConnectionSpecification#initialize
407
+
408
+ ```ruby
409
+ def initialize(name, config, adapter_method)
410
+ @name, @config, @adapter_method = name, config, adapter_method
411
+ end
412
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:213
413
+ ```
414
+ </details>
415
+ <details open>
416
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1028</summary>
417
+
418
+ ##### ActiveRecord::ConnectionAdapters::ConnectionHandler#remove_connection
419
+
420
+ ```ruby
421
+ def remove_connection(spec_name)
422
+ if pool = owner_to_pool.delete(spec_name)
423
+ pool.automatic_reconnect = false
424
+ pool.disconnect!
425
+ pool.spec.config
426
+ end
427
+ end
428
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:958
429
+ ```
430
+ </details>
431
+ <details open>
432
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1058</summary>
433
+
434
+ ##### ActiveRecord::ConnectionAdapters::ConnectionHandler#owner_to_pool
435
+
436
+ ```ruby
437
+ def owner_to_pool
438
+ @owner_to_pool[Process.pid]
439
+ end
440
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1029
441
+ ```
442
+ </details>
443
+ <details open>
444
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:132</summary>
445
+
446
+ ##### Concurrent::Map#[]
447
+
448
+ ```ruby
449
+ def [](key)
450
+ if value = super # non-falsy value is an existing mapping, return it right away
451
+ value
452
+ # re-check is done with get_or_default(key, NULL) instead of a simple !key?(key) in order to avoid a race condition, whereby by the time the current thread gets to the key?(key) call
453
+ # a key => value mapping might have already been created by a different thread (key?(key) would then return true, this elsif branch wouldn't be taken and an incorrent +nil+ value
454
+ # would be returned)
455
+ # note: nil == value check is not technically necessary
456
+ elsif @default_proc && nil == value && NULL == (value = get_or_default(key, NULL))
457
+ @default_proc.call(self, key)
458
+ else
459
+ value
460
+ end
461
+ end
462
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1059
463
+ ```
464
+ </details>
465
+ <details open>
466
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/non_concurrent_map_backend.rb:19</summary>
467
+
468
+ ##### Concurrent::Map#[]
469
+
470
+ ```ruby
471
+ def [](key)
472
+ if value = super # non-falsy value is an existing mapping, return it right away
473
+ value
474
+ # re-check is done with get_or_default(key, NULL) instead of a simple !key?(key) in order to avoid a race condition, whereby by the time the current thread gets to the key?(key) call
475
+ # a key => value mapping might have already been created by a different thread (key?(key) would then return true, this elsif branch wouldn't be taken and an incorrent +nil+ value
476
+ # would be returned)
477
+ # note: nil == value check is not technically necessary
478
+ elsif @default_proc && nil == value && NULL == (value = get_or_default(key, NULL))
479
+ @default_proc.call(self, key)
480
+ else
481
+ value
482
+ end
483
+ end
484
+ # called from vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:133
485
+ ```
486
+ </details>
487
+ <details open>
488
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/mri_map_backend.rb:53</summary>
489
+
490
+ ##### Concurrent::Collection::MriMapBackend#delete
491
+
492
+ ```ruby
493
+ def delete(key)
494
+ @write_lock.synchronize { super }
495
+ end
496
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1029
497
+ ```
498
+ </details>
499
+ <details open>
500
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/non_concurrent_map_backend.rb:79</summary>
501
+
502
+ ##### Concurrent::Collection::MriMapBackend#delete
503
+
504
+ ```ruby
505
+ def delete(key)
506
+ @write_lock.synchronize { super }
507
+ end
508
+ # called from vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/mri_map_backend.rb:54
509
+ ```
510
+ </details>
511
+ <details open>
512
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:454</summary>
513
+
514
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool#disconnect!
515
+
516
+ ```ruby
517
+ def disconnect!
518
+ disconnect(false)
519
+ end
520
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1031
521
+ ```
522
+ </details>
523
+ <details open>
524
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:432</summary>
525
+
526
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool#disconnect
527
+
528
+ ```ruby
529
+ def disconnect(raise_on_acquisition_timeout = true)
530
+ with_exclusively_acquired_all_connections(raise_on_acquisition_timeout) do
531
+ synchronize do
532
+ @connections.each do |conn|
533
+ if conn.in_use?
534
+ conn.steal!
535
+ checkin conn
536
+ end
537
+ conn.disconnect!
538
+ end
539
+ @connections = []
540
+ @available.clear
541
+ end
542
+ end
543
+ end
544
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:455
545
+ ```
546
+ </details>
547
+ <details open>
548
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:675</summary>
549
+
550
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool#with_exclusively_acquired_all_connections
551
+
552
+ ```ruby
553
+ def with_exclusively_acquired_all_connections(raise_on_acquisition_timeout = true)
554
+ with_new_connections_blocked do
555
+ attempt_to_checkout_all_existing_connections(raise_on_acquisition_timeout)
556
+ yield
557
+ end
558
+ end
559
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:433
560
+ ```
561
+ </details>
562
+ <details open>
563
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:748</summary>
564
+
565
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool#with_new_connections_blocked
566
+
567
+ ```ruby
568
+ def with_new_connections_blocked
569
+ synchronize do
570
+ @threads_blocking_new_connections += 1
571
+ end
572
+
573
+ yield
574
+ ensure
575
+ num_new_conns_required = 0
576
+
577
+ synchronize do
578
+ @threads_blocking_new_connections -= 1
579
+
580
+ if @threads_blocking_new_connections.zero?
581
+ @available.clear
582
+
583
+ num_new_conns_required = num_waiting_in_queue
584
+
585
+ @connections.each do |conn|
586
+ next if conn.in_use?
587
+
588
+ @available.add conn
589
+ num_new_conns_required -= 1
590
+ end
591
+ end
592
+ end
593
+
594
+ bulk_make_new_connections(num_new_conns_required) if num_new_conns_required > 0
595
+ end
596
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:676
597
+ ```
598
+ </details>
599
+ <details open>
600
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:227</summary>
601
+
602
+ ##### MonitorMixin#mon_synchronize
603
+
604
+ ```ruby
605
+ def mon_synchronize
606
+ mon_enter
607
+ begin
608
+ yield
609
+ ensure
610
+ mon_exit
611
+ end
612
+ end
613
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:749
614
+ ```
615
+ </details>
616
+ <details open>
617
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:187</summary>
618
+
619
+ ##### MonitorMixin#mon_enter
620
+
621
+ ```ruby
622
+ def mon_enter
623
+ if @mon_owner != Thread.current
624
+ @mon_mutex.lock
625
+ @mon_owner = Thread.current
626
+ @mon_count = 0
627
+ end
628
+ @mon_count += 1
629
+ end
630
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:228
631
+ ```
632
+ </details>
633
+ <details open>
634
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:199</summary>
635
+
636
+ ##### MonitorMixin#mon_exit
637
+
638
+ ```ruby
639
+ def mon_exit
640
+ mon_check_owner
641
+ @mon_count -=1
642
+ if @mon_count == 0
643
+ @mon_owner = nil
644
+ @mon_mutex.unlock
645
+ end
646
+ end
647
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:232
648
+ ```
649
+ </details>
650
+ <details open>
651
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:267</summary>
652
+
653
+ ##### MonitorMixin#mon_check_owner
654
+
655
+ ```ruby
656
+ def mon_check_owner
657
+ if @mon_owner != Thread.current
658
+ raise ThreadError, "current thread not owner"
659
+ end
660
+ end
661
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:200
662
+ ```
663
+ </details>
664
+ <details open>
665
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:682</summary>
666
+
667
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool#attempt_to_checkout_all_existing_connections
668
+
669
+ ```ruby
670
+ def attempt_to_checkout_all_existing_connections(raise_on_acquisition_timeout = true)
671
+ collected_conns = synchronize do
672
+ # account for our own connections
673
+ @connections.select { |conn| conn.owner == Thread.current }
674
+ end
675
+
676
+ newly_checked_out = []
677
+ timeout_time = Time.now + (@checkout_timeout * 2)
678
+
679
+ @available.with_a_bias_for(Thread.current) do
680
+ loop do
681
+ synchronize do
682
+ return if collected_conns.size == @connections.size && @now_connecting == 0
683
+ remaining_timeout = timeout_time - Time.now
684
+ remaining_timeout = 0 if remaining_timeout < 0
685
+ conn = checkout_for_exclusive_access(remaining_timeout)
686
+ collected_conns << conn
687
+ newly_checked_out << conn
688
+ end
689
+ end
690
+ end
691
+ rescue ExclusiveConnectionTimeoutError
692
+ # <tt>raise_on_acquisition_timeout == false</tt> means we are directed to ignore any
693
+ # timeouts and are expected to just give up: we've obtained as many connections
694
+ # as possible, note that in a case like that we don't return any of the
695
+ # +newly_checked_out+ connections.
696
+
697
+ if raise_on_acquisition_timeout
698
+ release_newly_checked_out = true
699
+ raise
700
+ end
701
+ rescue Exception # if something else went wrong
702
+ # this can't be a "naked" rescue, because we have should return conns
703
+ # even for non-StandardErrors
704
+ release_newly_checked_out = true
705
+ raise
706
+ ensure
707
+ if release_newly_checked_out && newly_checked_out
708
+ # releasing only those conns that were checked out in this method, conns
709
+ # checked outside this method (before it was called) are not for us to release
710
+ newly_checked_out.each { |conn| checkin(conn) }
711
+ end
712
+ end
713
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:677
714
+ ```
715
+ </details>
716
+ <details open>
717
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:227</summary>
718
+
719
+ ##### MonitorMixin#mon_synchronize
720
+
721
+ ```ruby
722
+ def mon_synchronize
723
+ mon_enter
724
+ begin
725
+ yield
726
+ ensure
727
+ mon_exit
728
+ end
729
+ end
730
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:683
731
+ ```
732
+ </details>
733
+ <details open>
734
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:187</summary>
735
+
736
+ ##### MonitorMixin#mon_enter
737
+
738
+ ```ruby
739
+ def mon_enter
740
+ if @mon_owner != Thread.current
741
+ @mon_mutex.lock
742
+ @mon_owner = Thread.current
743
+ @mon_count = 0
744
+ end
745
+ @mon_count += 1
746
+ end
747
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:228
748
+ ```
749
+ </details>
750
+ <details open>
751
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:199</summary>
752
+
753
+ ##### MonitorMixin#mon_exit
754
+
755
+ ```ruby
756
+ def mon_exit
757
+ mon_check_owner
758
+ @mon_count -=1
759
+ if @mon_count == 0
760
+ @mon_owner = nil
761
+ @mon_mutex.unlock
762
+ end
763
+ end
764
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:232
765
+ ```
766
+ </details>
767
+ <details open>
768
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:267</summary>
769
+
770
+ ##### MonitorMixin#mon_check_owner
771
+
772
+ ```ruby
773
+ def mon_check_owner
774
+ if @mon_owner != Thread.current
775
+ raise ThreadError, "current thread not owner"
776
+ end
777
+ end
778
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:200
779
+ ```
780
+ </details>
781
+ <details open>
782
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/core_ext/time/calculations.rb:261</summary>
783
+
784
+ ##### Time#plus_with_duration
785
+
786
+ ```ruby
787
+ def plus_with_duration(other) #:nodoc:
788
+ if ActiveSupport::Duration === other
789
+ other.since(self)
790
+ else
791
+ plus_without_duration(other)
792
+ end
793
+ end
794
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:689
795
+ ```
796
+ </details>
797
+ <details open>
798
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/duration.rb:144</summary>
799
+
800
+ ##### ActiveSupport::Duration.===
801
+
802
+ ```ruby
803
+ def ===(other) #:nodoc:
804
+ other.is_a?(Duration)
805
+ rescue ::NoMethodError
806
+ false
807
+ end
808
+ # called from vendor/bundle/gems/activesupport-5.2.3/lib/active_support/core_ext/time/calculations.rb:262
809
+ ```
810
+ </details>
811
+ <details open>
812
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:251</summary>
813
+
814
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool::BiasableQueue#with_a_bias_for
815
+
816
+ ```ruby
817
+ def with_a_bias_for(thread)
818
+ previous_cond = nil
819
+ new_cond = nil
820
+ synchronize do
821
+ previous_cond = @cond
822
+ @cond = new_cond = BiasedConditionVariable.new(@lock, @cond, thread)
823
+ end
824
+ yield
825
+ ensure
826
+ synchronize do
827
+ @cond = previous_cond if previous_cond
828
+ new_cond.broadcast_on_biased if new_cond # wake up any remaining sleepers
829
+ end
830
+ end
831
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:691
832
+ ```
833
+ </details>
834
+ <details open>
835
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:154</summary>
836
+
837
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool::Queue#synchronize
838
+
839
+ ```ruby
840
+ def synchronize(&block)
841
+ @lock.synchronize(&block)
842
+ end
843
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:254
844
+ ```
845
+ </details>
846
+ <details open>
847
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:227</summary>
848
+
849
+ ##### MonitorMixin#mon_synchronize
850
+
851
+ ```ruby
852
+ def mon_synchronize
853
+ mon_enter
854
+ begin
855
+ yield
856
+ ensure
857
+ mon_exit
858
+ end
859
+ end
860
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:155
861
+ ```
862
+ </details>
863
+ <details open>
864
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:187</summary>
865
+
866
+ ##### MonitorMixin#mon_enter
867
+
868
+ ```ruby
869
+ def mon_enter
870
+ if @mon_owner != Thread.current
871
+ @mon_mutex.lock
872
+ @mon_owner = Thread.current
873
+ @mon_count = 0
874
+ end
875
+ @mon_count += 1
876
+ end
877
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:228
878
+ ```
879
+ </details>
880
+ <details open>
881
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:215</summary>
882
+
883
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool::BiasableQueue::BiasedConditionVariable#initialize
884
+
885
+ ```ruby
886
+ def initialize(lock, other_cond, preferred_thread)
887
+ @real_cond = lock.new_cond
888
+ @other_cond = other_cond
889
+ @preferred_thread = preferred_thread
890
+ @num_waiting_on_real_cond = 0
891
+ end
892
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:256
893
+ ```
894
+ </details>
895
+ <details open>
896
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:241</summary>
897
+
898
+ ##### MonitorMixin#new_cond
899
+
900
+ ```ruby
901
+ def new_cond
902
+ return ConditionVariable.new(self)
903
+ end
904
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:216
905
+ ```
906
+ </details>
907
+ <details open>
908
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:156</summary>
909
+
910
+ ##### MonitorMixin::ConditionVariable#initialize
911
+
912
+ ```ruby
913
+ def initialize(monitor)
914
+ @monitor = monitor
915
+ @cond = Thread::ConditionVariable.new
916
+ end
917
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:242
918
+ ```
919
+ </details>
920
+ <details open>
921
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:199</summary>
922
+
923
+ ##### MonitorMixin#mon_exit
924
+
925
+ ```ruby
926
+ def mon_exit
927
+ mon_check_owner
928
+ @mon_count -=1
929
+ if @mon_count == 0
930
+ @mon_owner = nil
931
+ @mon_mutex.unlock
932
+ end
933
+ end
934
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:232
935
+ ```
936
+ </details>
937
+ <details open>
938
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:267</summary>
939
+
940
+ ##### MonitorMixin#mon_check_owner
941
+
942
+ ```ruby
943
+ def mon_check_owner
944
+ if @mon_owner != Thread.current
945
+ raise ThreadError, "current thread not owner"
946
+ end
947
+ end
948
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:200
949
+ ```
950
+ </details>
951
+ <details open>
952
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:227</summary>
953
+
954
+ ##### MonitorMixin#mon_synchronize
955
+
956
+ ```ruby
957
+ def mon_synchronize
958
+ mon_enter
959
+ begin
960
+ yield
961
+ ensure
962
+ mon_exit
963
+ end
964
+ end
965
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:693
966
+ ```
967
+ </details>
968
+ <details open>
969
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:187</summary>
970
+
971
+ ##### MonitorMixin#mon_enter
972
+
973
+ ```ruby
974
+ def mon_enter
975
+ if @mon_owner != Thread.current
976
+ @mon_mutex.lock
977
+ @mon_owner = Thread.current
978
+ @mon_count = 0
979
+ end
980
+ @mon_count += 1
981
+ end
982
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:228
983
+ ```
984
+ </details>
985
+ <details open>
986
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:199</summary>
987
+
988
+ ##### MonitorMixin#mon_exit
989
+
990
+ ```ruby
991
+ def mon_exit
992
+ mon_check_owner
993
+ @mon_count -=1
994
+ if @mon_count == 0
995
+ @mon_owner = nil
996
+ @mon_mutex.unlock
997
+ end
998
+ end
999
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:232
1000
+ ```
1001
+ </details>
1002
+ <details open>
1003
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:267</summary>
1004
+
1005
+ ##### MonitorMixin#mon_check_owner
1006
+
1007
+ ```ruby
1008
+ def mon_check_owner
1009
+ if @mon_owner != Thread.current
1010
+ raise ThreadError, "current thread not owner"
1011
+ end
1012
+ end
1013
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:200
1014
+ ```
1015
+ </details>
1016
+ <details open>
1017
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:154</summary>
1018
+
1019
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool::Queue#synchronize
1020
+
1021
+ ```ruby
1022
+ def synchronize(&block)
1023
+ @lock.synchronize(&block)
1024
+ end
1025
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:260
1026
+ ```
1027
+ </details>
1028
+ <details open>
1029
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:227</summary>
1030
+
1031
+ ##### MonitorMixin#mon_synchronize
1032
+
1033
+ ```ruby
1034
+ def mon_synchronize
1035
+ mon_enter
1036
+ begin
1037
+ yield
1038
+ ensure
1039
+ mon_exit
1040
+ end
1041
+ end
1042
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:155
1043
+ ```
1044
+ </details>
1045
+ <details open>
1046
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:187</summary>
1047
+
1048
+ ##### MonitorMixin#mon_enter
1049
+
1050
+ ```ruby
1051
+ def mon_enter
1052
+ if @mon_owner != Thread.current
1053
+ @mon_mutex.lock
1054
+ @mon_owner = Thread.current
1055
+ @mon_count = 0
1056
+ end
1057
+ @mon_count += 1
1058
+ end
1059
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:228
1060
+ ```
1061
+ </details>
1062
+ <details open>
1063
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:227</summary>
1064
+
1065
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool::BiasableQueue::BiasedConditionVariable#broadcast_on_biased
1066
+
1067
+ ```ruby
1068
+ def broadcast_on_biased
1069
+ @num_waiting_on_real_cond = 0
1070
+ @real_cond.broadcast
1071
+ end
1072
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:262
1073
+ ```
1074
+ </details>
1075
+ <details open>
1076
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:149</summary>
1077
+
1078
+ ##### MonitorMixin::ConditionVariable#broadcast
1079
+
1080
+ ```ruby
1081
+ def broadcast
1082
+ @monitor.__send__(:mon_check_owner)
1083
+ @cond.broadcast
1084
+ end
1085
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:229
1086
+ ```
1087
+ </details>
1088
+ <details open>
1089
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:267</summary>
1090
+
1091
+ ##### MonitorMixin#mon_check_owner
1092
+
1093
+ ```ruby
1094
+ def mon_check_owner
1095
+ if @mon_owner != Thread.current
1096
+ raise ThreadError, "current thread not owner"
1097
+ end
1098
+ end
1099
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:150
1100
+ ```
1101
+ </details>
1102
+ <details open>
1103
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:199</summary>
1104
+
1105
+ ##### MonitorMixin#mon_exit
1106
+
1107
+ ```ruby
1108
+ def mon_exit
1109
+ mon_check_owner
1110
+ @mon_count -=1
1111
+ if @mon_count == 0
1112
+ @mon_owner = nil
1113
+ @mon_mutex.unlock
1114
+ end
1115
+ end
1116
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:232
1117
+ ```
1118
+ </details>
1119
+ <details open>
1120
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:267</summary>
1121
+
1122
+ ##### MonitorMixin#mon_check_owner
1123
+
1124
+ ```ruby
1125
+ def mon_check_owner
1126
+ if @mon_owner != Thread.current
1127
+ raise ThreadError, "current thread not owner"
1128
+ end
1129
+ end
1130
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:200
1131
+ ```
1132
+ </details>
1133
+ <details open>
1134
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:227</summary>
1135
+
1136
+ ##### MonitorMixin#mon_synchronize
1137
+
1138
+ ```ruby
1139
+ def mon_synchronize
1140
+ mon_enter
1141
+ begin
1142
+ yield
1143
+ ensure
1144
+ mon_exit
1145
+ end
1146
+ end
1147
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:434
1148
+ ```
1149
+ </details>
1150
+ <details open>
1151
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:187</summary>
1152
+
1153
+ ##### MonitorMixin#mon_enter
1154
+
1155
+ ```ruby
1156
+ def mon_enter
1157
+ if @mon_owner != Thread.current
1158
+ @mon_mutex.lock
1159
+ @mon_owner = Thread.current
1160
+ @mon_count = 0
1161
+ end
1162
+ @mon_count += 1
1163
+ end
1164
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:228
1165
+ ```
1166
+ </details>
1167
+ <details open>
1168
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:124</summary>
1169
+
1170
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool::Queue#clear
1171
+
1172
+ ```ruby
1173
+ def clear
1174
+ synchronize do
1175
+ @queue.clear
1176
+ end
1177
+ end
1178
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:443
1179
+ ```
1180
+ </details>
1181
+ <details open>
1182
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:154</summary>
1183
+
1184
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool::Queue#synchronize
1185
+
1186
+ ```ruby
1187
+ def synchronize(&block)
1188
+ @lock.synchronize(&block)
1189
+ end
1190
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:125
1191
+ ```
1192
+ </details>
1193
+ <details open>
1194
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:227</summary>
1195
+
1196
+ ##### MonitorMixin#mon_synchronize
1197
+
1198
+ ```ruby
1199
+ def mon_synchronize
1200
+ mon_enter
1201
+ begin
1202
+ yield
1203
+ ensure
1204
+ mon_exit
1205
+ end
1206
+ end
1207
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:155
1208
+ ```
1209
+ </details>
1210
+ <details open>
1211
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:187</summary>
1212
+
1213
+ ##### MonitorMixin#mon_enter
1214
+
1215
+ ```ruby
1216
+ def mon_enter
1217
+ if @mon_owner != Thread.current
1218
+ @mon_mutex.lock
1219
+ @mon_owner = Thread.current
1220
+ @mon_count = 0
1221
+ end
1222
+ @mon_count += 1
1223
+ end
1224
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:228
1225
+ ```
1226
+ </details>
1227
+ <details open>
1228
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:199</summary>
1229
+
1230
+ ##### MonitorMixin#mon_exit
1231
+
1232
+ ```ruby
1233
+ def mon_exit
1234
+ mon_check_owner
1235
+ @mon_count -=1
1236
+ if @mon_count == 0
1237
+ @mon_owner = nil
1238
+ @mon_mutex.unlock
1239
+ end
1240
+ end
1241
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:232
1242
+ ```
1243
+ </details>
1244
+ <details open>
1245
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:267</summary>
1246
+
1247
+ ##### MonitorMixin#mon_check_owner
1248
+
1249
+ ```ruby
1250
+ def mon_check_owner
1251
+ if @mon_owner != Thread.current
1252
+ raise ThreadError, "current thread not owner"
1253
+ end
1254
+ end
1255
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:200
1256
+ ```
1257
+ </details>
1258
+ <details open>
1259
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:199</summary>
1260
+
1261
+ ##### MonitorMixin#mon_exit
1262
+
1263
+ ```ruby
1264
+ def mon_exit
1265
+ mon_check_owner
1266
+ @mon_count -=1
1267
+ if @mon_count == 0
1268
+ @mon_owner = nil
1269
+ @mon_mutex.unlock
1270
+ end
1271
+ end
1272
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:232
1273
+ ```
1274
+ </details>
1275
+ <details open>
1276
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:267</summary>
1277
+
1278
+ ##### MonitorMixin#mon_check_owner
1279
+
1280
+ ```ruby
1281
+ def mon_check_owner
1282
+ if @mon_owner != Thread.current
1283
+ raise ThreadError, "current thread not owner"
1284
+ end
1285
+ end
1286
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:200
1287
+ ```
1288
+ </details>
1289
+ <details open>
1290
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:227</summary>
1291
+
1292
+ ##### MonitorMixin#mon_synchronize
1293
+
1294
+ ```ruby
1295
+ def mon_synchronize
1296
+ mon_enter
1297
+ begin
1298
+ yield
1299
+ ensure
1300
+ mon_exit
1301
+ end
1302
+ end
1303
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:757
1304
+ ```
1305
+ </details>
1306
+ <details open>
1307
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:187</summary>
1308
+
1309
+ ##### MonitorMixin#mon_enter
1310
+
1311
+ ```ruby
1312
+ def mon_enter
1313
+ if @mon_owner != Thread.current
1314
+ @mon_mutex.lock
1315
+ @mon_owner = Thread.current
1316
+ @mon_count = 0
1317
+ end
1318
+ @mon_count += 1
1319
+ end
1320
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:228
1321
+ ```
1322
+ </details>
1323
+ <details open>
1324
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:124</summary>
1325
+
1326
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool::Queue#clear
1327
+
1328
+ ```ruby
1329
+ def clear
1330
+ synchronize do
1331
+ @queue.clear
1332
+ end
1333
+ end
1334
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:761
1335
+ ```
1336
+ </details>
1337
+ <details open>
1338
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:154</summary>
1339
+
1340
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool::Queue#synchronize
1341
+
1342
+ ```ruby
1343
+ def synchronize(&block)
1344
+ @lock.synchronize(&block)
1345
+ end
1346
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:125
1347
+ ```
1348
+ </details>
1349
+ <details open>
1350
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:227</summary>
1351
+
1352
+ ##### MonitorMixin#mon_synchronize
1353
+
1354
+ ```ruby
1355
+ def mon_synchronize
1356
+ mon_enter
1357
+ begin
1358
+ yield
1359
+ ensure
1360
+ mon_exit
1361
+ end
1362
+ end
1363
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:155
1364
+ ```
1365
+ </details>
1366
+ <details open>
1367
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:187</summary>
1368
+
1369
+ ##### MonitorMixin#mon_enter
1370
+
1371
+ ```ruby
1372
+ def mon_enter
1373
+ if @mon_owner != Thread.current
1374
+ @mon_mutex.lock
1375
+ @mon_owner = Thread.current
1376
+ @mon_count = 0
1377
+ end
1378
+ @mon_count += 1
1379
+ end
1380
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:228
1381
+ ```
1382
+ </details>
1383
+ <details open>
1384
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:199</summary>
1385
+
1386
+ ##### MonitorMixin#mon_exit
1387
+
1388
+ ```ruby
1389
+ def mon_exit
1390
+ mon_check_owner
1391
+ @mon_count -=1
1392
+ if @mon_count == 0
1393
+ @mon_owner = nil
1394
+ @mon_mutex.unlock
1395
+ end
1396
+ end
1397
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:232
1398
+ ```
1399
+ </details>
1400
+ <details open>
1401
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:267</summary>
1402
+
1403
+ ##### MonitorMixin#mon_check_owner
1404
+
1405
+ ```ruby
1406
+ def mon_check_owner
1407
+ if @mon_owner != Thread.current
1408
+ raise ThreadError, "current thread not owner"
1409
+ end
1410
+ end
1411
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:200
1412
+ ```
1413
+ </details>
1414
+ <details open>
1415
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:627</summary>
1416
+
1417
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool#num_waiting_in_queue
1418
+
1419
+ ```ruby
1420
+ def num_waiting_in_queue # :nodoc:
1421
+ @available.num_waiting
1422
+ end
1423
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:763
1424
+ ```
1425
+ </details>
1426
+ <details open>
1427
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:102</summary>
1428
+
1429
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool::Queue#num_waiting
1430
+
1431
+ ```ruby
1432
+ def num_waiting
1433
+ synchronize do
1434
+ @num_waiting
1435
+ end
1436
+ end
1437
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:628
1438
+ ```
1439
+ </details>
1440
+ <details open>
1441
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:154</summary>
1442
+
1443
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool::Queue#synchronize
1444
+
1445
+ ```ruby
1446
+ def synchronize(&block)
1447
+ @lock.synchronize(&block)
1448
+ end
1449
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:103
1450
+ ```
1451
+ </details>
1452
+ <details open>
1453
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:227</summary>
1454
+
1455
+ ##### MonitorMixin#mon_synchronize
1456
+
1457
+ ```ruby
1458
+ def mon_synchronize
1459
+ mon_enter
1460
+ begin
1461
+ yield
1462
+ ensure
1463
+ mon_exit
1464
+ end
1465
+ end
1466
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:155
1467
+ ```
1468
+ </details>
1469
+ <details open>
1470
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:187</summary>
1471
+
1472
+ ##### MonitorMixin#mon_enter
1473
+
1474
+ ```ruby
1475
+ def mon_enter
1476
+ if @mon_owner != Thread.current
1477
+ @mon_mutex.lock
1478
+ @mon_owner = Thread.current
1479
+ @mon_count = 0
1480
+ end
1481
+ @mon_count += 1
1482
+ end
1483
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:228
1484
+ ```
1485
+ </details>
1486
+ <details open>
1487
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:199</summary>
1488
+
1489
+ ##### MonitorMixin#mon_exit
1490
+
1491
+ ```ruby
1492
+ def mon_exit
1493
+ mon_check_owner
1494
+ @mon_count -=1
1495
+ if @mon_count == 0
1496
+ @mon_owner = nil
1497
+ @mon_mutex.unlock
1498
+ end
1499
+ end
1500
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:232
1501
+ ```
1502
+ </details>
1503
+ <details open>
1504
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:267</summary>
1505
+
1506
+ ##### MonitorMixin#mon_check_owner
1507
+
1508
+ ```ruby
1509
+ def mon_check_owner
1510
+ if @mon_owner != Thread.current
1511
+ raise ThreadError, "current thread not owner"
1512
+ end
1513
+ end
1514
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:200
1515
+ ```
1516
+ </details>
1517
+ <details open>
1518
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:199</summary>
1519
+
1520
+ ##### MonitorMixin#mon_exit
1521
+
1522
+ ```ruby
1523
+ def mon_exit
1524
+ mon_check_owner
1525
+ @mon_count -=1
1526
+ if @mon_count == 0
1527
+ @mon_owner = nil
1528
+ @mon_mutex.unlock
1529
+ end
1530
+ end
1531
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:232
1532
+ ```
1533
+ </details>
1534
+ <details open>
1535
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:267</summary>
1536
+
1537
+ ##### MonitorMixin#mon_check_owner
1538
+
1539
+ ```ruby
1540
+ def mon_check_owner
1541
+ if @mon_owner != Thread.current
1542
+ raise ThreadError, "current thread not owner"
1543
+ end
1544
+ end
1545
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:200
1546
+ ```
1547
+ </details>
1548
+ <details open>
1549
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications.rb:189</summary>
1550
+
1551
+ ##### ActiveSupport::Notifications.instrumenter
1552
+
1553
+ ```ruby
1554
+ def instrumenter
1555
+ InstrumentationRegistry.instance.instrumenter_for(notifier)
1556
+ end
1557
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:960
1558
+ ```
1559
+ </details>
1560
+ <details open>
1561
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/per_thread_registry.rb:46</summary>
1562
+
1563
+ ##### ActiveSupport::PerThreadRegistry.instance
1564
+
1565
+ ```ruby
1566
+ def instance
1567
+ Thread.current[@per_thread_registry_key] ||= new
1568
+ end
1569
+ # called from vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications.rb:190
1570
+ ```
1571
+ </details>
1572
+ <details open>
1573
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications.rb:209</summary>
1574
+
1575
+ ##### ActiveSupport::Notifications::InstrumentationRegistry#instrumenter_for
1576
+
1577
+ ```ruby
1578
+ def instrumenter_for(notifier)
1579
+ @registry[notifier] ||= Instrumenter.new(notifier)
1580
+ end
1581
+ # called from vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications.rb:190
1582
+ ```
1583
+ </details>
1584
+ <details open>
1585
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb:19</summary>
1586
+
1587
+ ##### ActiveSupport::Notifications::Instrumenter#instrument
1588
+
1589
+ ```ruby
1590
+ def instrument(name, payload = {})
1591
+ # some of the listeners might have state
1592
+ listeners_state = start name, payload
1593
+ begin
1594
+ yield payload
1595
+ rescue Exception => e
1596
+ payload[:exception] = [e.class.name, e.message]
1597
+ payload[:exception_object] = e
1598
+ raise e
1599
+ ensure
1600
+ finish_with_state listeners_state, name, payload
1601
+ end
1602
+ end
1603
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:969
1604
+ ```
1605
+ </details>
1606
+ <details open>
1607
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb:34</summary>
1608
+
1609
+ ##### ActiveSupport::Notifications::Instrumenter#start
1610
+
1611
+ ```ruby
1612
+ def start(name, payload)
1613
+ @notifier.start name, @id, payload
1614
+ end
1615
+ # called from vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb:21
1616
+ ```
1617
+ </details>
1618
+ <details open>
1619
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications/fanout.rb:43</summary>
1620
+
1621
+ ##### ActiveSupport::Notifications::Fanout#start
1622
+
1623
+ ```ruby
1624
+ def start(name, id, payload)
1625
+ listeners_for(name).each { |s| s.start(name, id, payload) }
1626
+ end
1627
+ # called from vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb:35
1628
+ ```
1629
+ </details>
1630
+ <details open>
1631
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications/fanout.rb:55</summary>
1632
+
1633
+ ##### ActiveSupport::Notifications::Fanout#listeners_for
1634
+
1635
+ ```ruby
1636
+ def listeners_for(name)
1637
+ # this is correctly done double-checked locking (Concurrent::Map's lookups have volatile semantics)
1638
+ @listeners_for[name] || synchronize do
1639
+ # use synchronisation when accessing @subscribers
1640
+ @listeners_for[name] ||= @subscribers.select { |s| s.subscribed_to?(name) }
1641
+ end
1642
+ end
1643
+ # called from vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications/fanout.rb:44
1644
+ ```
1645
+ </details>
1646
+ <details open>
1647
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:132</summary>
1648
+
1649
+ ##### Concurrent::Map#[]
1650
+
1651
+ ```ruby
1652
+ def [](key)
1653
+ if value = super # non-falsy value is an existing mapping, return it right away
1654
+ value
1655
+ # re-check is done with get_or_default(key, NULL) instead of a simple !key?(key) in order to avoid a race condition, whereby by the time the current thread gets to the key?(key) call
1656
+ # a key => value mapping might have already been created by a different thread (key?(key) would then return true, this elsif branch wouldn't be taken and an incorrent +nil+ value
1657
+ # would be returned)
1658
+ # note: nil == value check is not technically necessary
1659
+ elsif @default_proc && nil == value && NULL == (value = get_or_default(key, NULL))
1660
+ @default_proc.call(self, key)
1661
+ else
1662
+ value
1663
+ end
1664
+ end
1665
+ # called from vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications/fanout.rb:57
1666
+ ```
1667
+ </details>
1668
+ <details open>
1669
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/non_concurrent_map_backend.rb:19</summary>
1670
+
1671
+ ##### Concurrent::Map#[]
1672
+
1673
+ ```ruby
1674
+ def [](key)
1675
+ if value = super # non-falsy value is an existing mapping, return it right away
1676
+ value
1677
+ # re-check is done with get_or_default(key, NULL) instead of a simple !key?(key) in order to avoid a race condition, whereby by the time the current thread gets to the key?(key) call
1678
+ # a key => value mapping might have already been created by a different thread (key?(key) would then return true, this elsif branch wouldn't be taken and an incorrent +nil+ value
1679
+ # would be returned)
1680
+ # note: nil == value check is not technically necessary
1681
+ elsif @default_proc && nil == value && NULL == (value = get_or_default(key, NULL))
1682
+ @default_proc.call(self, key)
1683
+ else
1684
+ value
1685
+ end
1686
+ end
1687
+ # called from vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:133
1688
+ ```
1689
+ </details>
1690
+ <details open>
1691
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1058</summary>
1692
+
1693
+ ##### ActiveRecord::ConnectionAdapters::ConnectionHandler#owner_to_pool
1694
+
1695
+ ```ruby
1696
+ def owner_to_pool
1697
+ @owner_to_pool[Process.pid]
1698
+ end
1699
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:970
1700
+ ```
1701
+ </details>
1702
+ <details open>
1703
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:132</summary>
1704
+
1705
+ ##### Concurrent::Map#[]
1706
+
1707
+ ```ruby
1708
+ def [](key)
1709
+ if value = super # non-falsy value is an existing mapping, return it right away
1710
+ value
1711
+ # re-check is done with get_or_default(key, NULL) instead of a simple !key?(key) in order to avoid a race condition, whereby by the time the current thread gets to the key?(key) call
1712
+ # a key => value mapping might have already been created by a different thread (key?(key) would then return true, this elsif branch wouldn't be taken and an incorrent +nil+ value
1713
+ # would be returned)
1714
+ # note: nil == value check is not technically necessary
1715
+ elsif @default_proc && nil == value && NULL == (value = get_or_default(key, NULL))
1716
+ @default_proc.call(self, key)
1717
+ else
1718
+ value
1719
+ end
1720
+ end
1721
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1059
1722
+ ```
1723
+ </details>
1724
+ <details open>
1725
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/non_concurrent_map_backend.rb:19</summary>
1726
+
1727
+ ##### Concurrent::Map#[]
1728
+
1729
+ ```ruby
1730
+ def [](key)
1731
+ if value = super # non-falsy value is an existing mapping, return it right away
1732
+ value
1733
+ # re-check is done with get_or_default(key, NULL) instead of a simple !key?(key) in order to avoid a race condition, whereby by the time the current thread gets to the key?(key) call
1734
+ # a key => value mapping might have already been created by a different thread (key?(key) would then return true, this elsif branch wouldn't be taken and an incorrent +nil+ value
1735
+ # would be returned)
1736
+ # note: nil == value check is not technically necessary
1737
+ elsif @default_proc && nil == value && NULL == (value = get_or_default(key, NULL))
1738
+ @default_proc.call(self, key)
1739
+ else
1740
+ value
1741
+ end
1742
+ end
1743
+ # called from vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:133
1744
+ ```
1745
+ </details>
1746
+ <details open>
1747
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:321</summary>
1748
+
1749
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool#initialize
1750
+
1751
+ ```ruby
1752
+ def initialize(spec)
1753
+ super()
1754
+
1755
+ @spec = spec
1756
+
1757
+ @checkout_timeout = (spec.config[:checkout_timeout] && spec.config[:checkout_timeout].to_f) || 5
1758
+ if @idle_timeout = spec.config.fetch(:idle_timeout, 300)
1759
+ @idle_timeout = @idle_timeout.to_f
1760
+ @idle_timeout = nil if @idle_timeout <= 0
1761
+ end
1762
+
1763
+ # default max pool size to 5
1764
+ @size = (spec.config[:pool] && spec.config[:pool].to_i) || 5
1765
+
1766
+ # This variable tracks the cache of threads mapped to reserved connections, with the
1767
+ # sole purpose of speeding up the +connection+ method. It is not the authoritative
1768
+ # registry of which thread owns which connection. Connection ownership is tracked by
1769
+ # the +connection.owner+ attr on each +connection+ instance.
1770
+ # The invariant works like this: if there is mapping of <tt>thread => conn</tt>,
1771
+ # then that +thread+ does indeed own that +conn+. However, an absence of a such
1772
+ # mapping does not mean that the +thread+ doesn't own the said connection. In
1773
+ # that case +conn.owner+ attr should be consulted.
1774
+ # Access and modification of <tt>@thread_cached_conns</tt> does not require
1775
+ # synchronization.
1776
+ @thread_cached_conns = Concurrent::Map.new(initial_capacity: @size)
1777
+
1778
+ @connections = []
1779
+ @automatic_reconnect = true
1780
+
1781
+ # Connection pool allows for concurrent (outside the main +synchronize+ section)
1782
+ # establishment of new connections. This variable tracks the number of threads
1783
+ # currently in the process of independently establishing connections to the DB.
1784
+ @now_connecting = 0
1785
+
1786
+ @threads_blocking_new_connections = 0
1787
+
1788
+ @available = ConnectionLeasingQueue.new self
1789
+
1790
+ @lock_thread = false
1791
+
1792
+ # +reaping_frequency+ is configurable mostly for historical reasons, but it could
1793
+ # also be useful if someone wants a very low +idle_timeout+.
1794
+ reaping_frequency = spec.config.fetch(:reaping_frequency, 60)
1795
+ @reaper = Reaper.new(self, reaping_frequency && reaping_frequency.to_f)
1796
+ @reaper.run
1797
+ end
1798
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:970
1799
+ ```
1800
+ </details>
1801
+ <details open>
1802
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/query_cache.rb:29</summary>
1803
+
1804
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool#initialize
1805
+
1806
+ ```ruby
1807
+ def initialize(spec)
1808
+ super()
1809
+
1810
+ @spec = spec
1811
+
1812
+ @checkout_timeout = (spec.config[:checkout_timeout] && spec.config[:checkout_timeout].to_f) || 5
1813
+ if @idle_timeout = spec.config.fetch(:idle_timeout, 300)
1814
+ @idle_timeout = @idle_timeout.to_f
1815
+ @idle_timeout = nil if @idle_timeout <= 0
1816
+ end
1817
+
1818
+ # default max pool size to 5
1819
+ @size = (spec.config[:pool] && spec.config[:pool].to_i) || 5
1820
+
1821
+ # This variable tracks the cache of threads mapped to reserved connections, with the
1822
+ # sole purpose of speeding up the +connection+ method. It is not the authoritative
1823
+ # registry of which thread owns which connection. Connection ownership is tracked by
1824
+ # the +connection.owner+ attr on each +connection+ instance.
1825
+ # The invariant works like this: if there is mapping of <tt>thread => conn</tt>,
1826
+ # then that +thread+ does indeed own that +conn+. However, an absence of a such
1827
+ # mapping does not mean that the +thread+ doesn't own the said connection. In
1828
+ # that case +conn.owner+ attr should be consulted.
1829
+ # Access and modification of <tt>@thread_cached_conns</tt> does not require
1830
+ # synchronization.
1831
+ @thread_cached_conns = Concurrent::Map.new(initial_capacity: @size)
1832
+
1833
+ @connections = []
1834
+ @automatic_reconnect = true
1835
+
1836
+ # Connection pool allows for concurrent (outside the main +synchronize+ section)
1837
+ # establishment of new connections. This variable tracks the number of threads
1838
+ # currently in the process of independently establishing connections to the DB.
1839
+ @now_connecting = 0
1840
+
1841
+ @threads_blocking_new_connections = 0
1842
+
1843
+ @available = ConnectionLeasingQueue.new self
1844
+
1845
+ @lock_thread = false
1846
+
1847
+ # +reaping_frequency+ is configurable mostly for historical reasons, but it could
1848
+ # also be useful if someone wants a very low +idle_timeout+.
1849
+ reaping_frequency = spec.config.fetch(:reaping_frequency, 60)
1850
+ @reaper = Reaper.new(self, reaping_frequency && reaping_frequency.to_f)
1851
+ @reaper.run
1852
+ end
1853
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:322
1854
+ ```
1855
+ </details>
1856
+ <details open>
1857
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:250</summary>
1858
+
1859
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool#initialize
1860
+
1861
+ ```ruby
1862
+ def initialize(spec)
1863
+ super()
1864
+
1865
+ @spec = spec
1866
+
1867
+ @checkout_timeout = (spec.config[:checkout_timeout] && spec.config[:checkout_timeout].to_f) || 5
1868
+ if @idle_timeout = spec.config.fetch(:idle_timeout, 300)
1869
+ @idle_timeout = @idle_timeout.to_f
1870
+ @idle_timeout = nil if @idle_timeout <= 0
1871
+ end
1872
+
1873
+ # default max pool size to 5
1874
+ @size = (spec.config[:pool] && spec.config[:pool].to_i) || 5
1875
+
1876
+ # This variable tracks the cache of threads mapped to reserved connections, with the
1877
+ # sole purpose of speeding up the +connection+ method. It is not the authoritative
1878
+ # registry of which thread owns which connection. Connection ownership is tracked by
1879
+ # the +connection.owner+ attr on each +connection+ instance.
1880
+ # The invariant works like this: if there is mapping of <tt>thread => conn</tt>,
1881
+ # then that +thread+ does indeed own that +conn+. However, an absence of a such
1882
+ # mapping does not mean that the +thread+ doesn't own the said connection. In
1883
+ # that case +conn.owner+ attr should be consulted.
1884
+ # Access and modification of <tt>@thread_cached_conns</tt> does not require
1885
+ # synchronization.
1886
+ @thread_cached_conns = Concurrent::Map.new(initial_capacity: @size)
1887
+
1888
+ @connections = []
1889
+ @automatic_reconnect = true
1890
+
1891
+ # Connection pool allows for concurrent (outside the main +synchronize+ section)
1892
+ # establishment of new connections. This variable tracks the number of threads
1893
+ # currently in the process of independently establishing connections to the DB.
1894
+ @now_connecting = 0
1895
+
1896
+ @threads_blocking_new_connections = 0
1897
+
1898
+ @available = ConnectionLeasingQueue.new self
1899
+
1900
+ @lock_thread = false
1901
+
1902
+ # +reaping_frequency+ is configurable mostly for historical reasons, but it could
1903
+ # also be useful if someone wants a very low +idle_timeout+.
1904
+ reaping_frequency = spec.config.fetch(:reaping_frequency, 60)
1905
+ @reaper = Reaper.new(self, reaping_frequency && reaping_frequency.to_f)
1906
+ @reaper.run
1907
+ end
1908
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/query_cache.rb:30
1909
+ ```
1910
+ </details>
1911
+ <details open>
1912
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:257</summary>
1913
+
1914
+ ##### MonitorMixin#mon_initialize
1915
+
1916
+ ```ruby
1917
+ def mon_initialize
1918
+ if defined?(@mon_mutex) && @mon_mutex_owner_object_id == object_id
1919
+ raise ThreadError, "already initialized"
1920
+ end
1921
+ @mon_mutex = Thread::Mutex.new
1922
+ @mon_mutex_owner_object_id = object_id
1923
+ @mon_owner = nil
1924
+ @mon_count = 0
1925
+ end
1926
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:252
1927
+ ```
1928
+ </details>
1929
+ <details open>
1930
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:118</summary>
1931
+
1932
+ ##### Concurrent::Map#initialize
1933
+
1934
+ ```ruby
1935
+ def initialize(options = nil, &block)
1936
+ if options.kind_of?(::Hash)
1937
+ validate_options_hash!(options)
1938
+ else
1939
+ options = nil
1940
+ end
1941
+
1942
+ super(options)
1943
+ @default_proc = block
1944
+ end
1945
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/query_cache.rb:31
1946
+ ```
1947
+ </details>
1948
+ <details open>
1949
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/mri_map_backend.rb:12</summary>
1950
+
1951
+ ##### Concurrent::Map#initialize
1952
+
1953
+ ```ruby
1954
+ def initialize(options = nil, &block)
1955
+ if options.kind_of?(::Hash)
1956
+ validate_options_hash!(options)
1957
+ else
1958
+ options = nil
1959
+ end
1960
+
1961
+ super(options)
1962
+ @default_proc = block
1963
+ end
1964
+ # called from vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:125
1965
+ ```
1966
+ </details>
1967
+ <details open>
1968
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/non_concurrent_map_backend.rb:15</summary>
1969
+
1970
+ ##### Concurrent::Map#initialize
1971
+
1972
+ ```ruby
1973
+ def initialize(options = nil, &block)
1974
+ if options.kind_of?(::Hash)
1975
+ validate_options_hash!(options)
1976
+ else
1977
+ options = nil
1978
+ end
1979
+
1980
+ super(options)
1981
+ @default_proc = block
1982
+ end
1983
+ # called from vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/mri_map_backend.rb:13
1984
+ ```
1985
+ </details>
1986
+ <details open>
1987
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:118</summary>
1988
+
1989
+ ##### Concurrent::Map#initialize
1990
+
1991
+ ```ruby
1992
+ def initialize(options = nil, &block)
1993
+ if options.kind_of?(::Hash)
1994
+ validate_options_hash!(options)
1995
+ else
1996
+ options = nil
1997
+ end
1998
+
1999
+ super(options)
2000
+ @default_proc = block
2001
+ end
2002
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:345
2003
+ ```
2004
+ </details>
2005
+ <details open>
2006
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:328</summary>
2007
+
2008
+ ##### Concurrent::Map#validate_options_hash!
2009
+
2010
+ ```ruby
2011
+ def validate_options_hash!(options)
2012
+ if (initial_capacity = options[:initial_capacity]) && (!initial_capacity.kind_of?(Integer) || initial_capacity < 0)
2013
+ raise ArgumentError, ":initial_capacity must be a positive Integer"
2014
+ end
2015
+ if (load_factor = options[:load_factor]) && (!load_factor.kind_of?(Numeric) || load_factor <= 0 || load_factor > 1)
2016
+ raise ArgumentError, ":load_factor must be a number between 0 and 1"
2017
+ end
2018
+ end
2019
+ # called from vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:120
2020
+ ```
2021
+ </details>
2022
+ <details open>
2023
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/mri_map_backend.rb:12</summary>
2024
+
2025
+ ##### Concurrent::Map#initialize
2026
+
2027
+ ```ruby
2028
+ def initialize(options = nil, &block)
2029
+ if options.kind_of?(::Hash)
2030
+ validate_options_hash!(options)
2031
+ else
2032
+ options = nil
2033
+ end
2034
+
2035
+ super(options)
2036
+ @default_proc = block
2037
+ end
2038
+ # called from vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:125
2039
+ ```
2040
+ </details>
2041
+ <details open>
2042
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/non_concurrent_map_backend.rb:15</summary>
2043
+
2044
+ ##### Concurrent::Map#initialize
2045
+
2046
+ ```ruby
2047
+ def initialize(options = nil, &block)
2048
+ if options.kind_of?(::Hash)
2049
+ validate_options_hash!(options)
2050
+ else
2051
+ options = nil
2052
+ end
2053
+
2054
+ super(options)
2055
+ @default_proc = block
2056
+ end
2057
+ # called from vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/mri_map_backend.rb:13
2058
+ ```
2059
+ </details>
2060
+ <details open>
2061
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:86</summary>
2062
+
2063
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool::Queue#initialize
2064
+
2065
+ ```ruby
2066
+ def initialize(lock = Monitor.new)
2067
+ @lock = lock
2068
+ @cond = @lock.new_cond
2069
+ @num_waiting = 0
2070
+ @queue = []
2071
+ end
2072
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:357
2073
+ ```
2074
+ </details>
2075
+ <details open>
2076
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:241</summary>
2077
+
2078
+ ##### MonitorMixin#new_cond
2079
+
2080
+ ```ruby
2081
+ def new_cond
2082
+ return ConditionVariable.new(self)
2083
+ end
2084
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:88
2085
+ ```
2086
+ </details>
2087
+ <details open>
2088
+ <summary>/Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:156</summary>
2089
+
2090
+ ##### MonitorMixin::ConditionVariable#initialize
2091
+
2092
+ ```ruby
2093
+ def initialize(monitor)
2094
+ @monitor = monitor
2095
+ @cond = Thread::ConditionVariable.new
2096
+ end
2097
+ # called from /Users/yhirano/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:242
2098
+ ```
2099
+ </details>
2100
+ <details open>
2101
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:292</summary>
2102
+
2103
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool::Reaper#initialize
2104
+
2105
+ ```ruby
2106
+ def initialize(pool, frequency)
2107
+ @pool = pool
2108
+ @frequency = frequency
2109
+ end
2110
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:364
2111
+ ```
2112
+ </details>
2113
+ <details open>
2114
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:297</summary>
2115
+
2116
+ ##### ActiveRecord::ConnectionAdapters::ConnectionPool::Reaper#run
2117
+
2118
+ ```ruby
2119
+ def run
2120
+ return unless frequency && frequency > 0
2121
+ Thread.new(frequency, pool) { |t, p|
2122
+ loop do
2123
+ sleep t
2124
+ p.reap
2125
+ p.flush
2126
+ end
2127
+ }
2128
+ end
2129
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:365
2130
+ ```
2131
+ </details>
2132
+ <details open>
2133
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/mri_map_backend.rb:17</summary>
2134
+
2135
+ ##### Concurrent::Collection::MriMapBackend#[]=
2136
+
2137
+ ```ruby
2138
+ def []=(key, value)
2139
+ @write_lock.synchronize { super }
2140
+ end
2141
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:970
2142
+ ```
2143
+ </details>
2144
+ <details open>
2145
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/non_concurrent_map_backend.rb:23</summary>
2146
+
2147
+ ##### Concurrent::Collection::MriMapBackend#[]=
2148
+
2149
+ ```ruby
2150
+ def []=(key, value)
2151
+ @write_lock.synchronize { super }
2152
+ end
2153
+ # called from vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/mri_map_backend.rb:18
2154
+ ```
2155
+ </details>
2156
+ <details open>
2157
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb:43</summary>
2158
+
2159
+ ##### ActiveSupport::Notifications::Instrumenter#finish_with_state
2160
+
2161
+ ```ruby
2162
+ def finish_with_state(listeners_state, name, payload)
2163
+ @notifier.finish name, @id, payload, listeners_state
2164
+ end
2165
+ # called from vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb:29
2166
+ ```
2167
+ </details>
2168
+ <details open>
2169
+ <summary>vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications/fanout.rb:47</summary>
2170
+
2171
+ ##### ActiveSupport::Notifications::Fanout#finish
2172
+
2173
+ ```ruby
2174
+ def finish(name, id, payload, listeners = listeners_for(name))
2175
+ listeners.each { |s| s.finish(name, id, payload) }
2176
+ end
2177
+ # called from vendor/bundle/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb:44
2178
+ ```
2179
+ </details>
2180
+ <details open>
2181
+ <summary>vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1058</summary>
2182
+
2183
+ ##### ActiveRecord::ConnectionAdapters::ConnectionHandler#owner_to_pool
2184
+
2185
+ ```ruby
2186
+ def owner_to_pool
2187
+ @owner_to_pool[Process.pid]
2188
+ end
2189
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:973
2190
+ ```
2191
+ </details>
2192
+ <details open>
2193
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:132</summary>
2194
+
2195
+ ##### Concurrent::Map#[]
2196
+
2197
+ ```ruby
2198
+ def [](key)
2199
+ if value = super # non-falsy value is an existing mapping, return it right away
2200
+ value
2201
+ # re-check is done with get_or_default(key, NULL) instead of a simple !key?(key) in order to avoid a race condition, whereby by the time the current thread gets to the key?(key) call
2202
+ # a key => value mapping might have already been created by a different thread (key?(key) would then return true, this elsif branch wouldn't be taken and an incorrent +nil+ value
2203
+ # would be returned)
2204
+ # note: nil == value check is not technically necessary
2205
+ elsif @default_proc && nil == value && NULL == (value = get_or_default(key, NULL))
2206
+ @default_proc.call(self, key)
2207
+ else
2208
+ value
2209
+ end
2210
+ end
2211
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1059
2212
+ ```
2213
+ </details>
2214
+ <details open>
2215
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/non_concurrent_map_backend.rb:19</summary>
2216
+
2217
+ ##### Concurrent::Map#[]
2218
+
2219
+ ```ruby
2220
+ def [](key)
2221
+ if value = super # non-falsy value is an existing mapping, return it right away
2222
+ value
2223
+ # re-check is done with get_or_default(key, NULL) instead of a simple !key?(key) in order to avoid a race condition, whereby by the time the current thread gets to the key?(key) call
2224
+ # a key => value mapping might have already been created by a different thread (key?(key) would then return true, this elsif branch wouldn't be taken and an incorrent +nil+ value
2225
+ # would be returned)
2226
+ # note: nil == value check is not technically necessary
2227
+ elsif @default_proc && nil == value && NULL == (value = get_or_default(key, NULL))
2228
+ @default_proc.call(self, key)
2229
+ else
2230
+ value
2231
+ end
2232
+ end
2233
+ # called from vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:133
2234
+ ```
2235
+ </details>
2236
+ <details open>
2237
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:132</summary>
2238
+
2239
+ ##### Concurrent::Map#[]
2240
+
2241
+ ```ruby
2242
+ def [](key)
2243
+ if value = super # non-falsy value is an existing mapping, return it right away
2244
+ value
2245
+ # re-check is done with get_or_default(key, NULL) instead of a simple !key?(key) in order to avoid a race condition, whereby by the time the current thread gets to the key?(key) call
2246
+ # a key => value mapping might have already been created by a different thread (key?(key) would then return true, this elsif branch wouldn't be taken and an incorrent +nil+ value
2247
+ # would be returned)
2248
+ # note: nil == value check is not technically necessary
2249
+ elsif @default_proc && nil == value && NULL == (value = get_or_default(key, NULL))
2250
+ @default_proc.call(self, key)
2251
+ else
2252
+ value
2253
+ end
2254
+ end
2255
+ # called from vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:973
2256
+ ```
2257
+ </details>
2258
+ <details open>
2259
+ <summary>vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/collection/map/non_concurrent_map_backend.rb:19</summary>
2260
+
2261
+ ##### Concurrent::Map#[]
2262
+
2263
+ ```ruby
2264
+ def [](key)
2265
+ if value = super # non-falsy value is an existing mapping, return it right away
2266
+ value
2267
+ # re-check is done with get_or_default(key, NULL) instead of a simple !key?(key) in order to avoid a race condition, whereby by the time the current thread gets to the key?(key) call
2268
+ # a key => value mapping might have already been created by a different thread (key?(key) would then return true, this elsif branch wouldn't be taken and an incorrent +nil+ value
2269
+ # would be returned)
2270
+ # note: nil == value check is not technically necessary
2271
+ elsif @default_proc && nil == value && NULL == (value = get_or_default(key, NULL))
2272
+ @default_proc.call(self, key)
2273
+ else
2274
+ value
2275
+ end
2276
+ end
2277
+ # called from vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:133
2278
+ ```
2279
+ </details>