class DbSucker::Patches::ThreadCounter
Public Class Methods
hook!(app)
click to toggle source
# File lib/db_sucker/patches/thread-count.rb, line 7 def self.hook!(app) $thread_count = 0 $thread_count_monitor = Monitor.new ::Thread.class_eval do class << self def new_with_counter *a, &b $thread_count_monitor.synchronize { $thread_count += 1 } new_without_counter(*a, &b) end alias_method :new_without_counter, :new alias_method :new, :new_with_counter end end app.hook :core_shutdown do app.debug "#{$thread_count} threads spawned" end end
new_with_counter(*a, &b)
click to toggle source
# File lib/db_sucker/patches/thread-count.rb, line 13 def new_with_counter *a, &b $thread_count_monitor.synchronize { $thread_count += 1 } new_without_counter(*a, &b) end
Also aliased as: new