class TestProf::EventProf::Monitor::TopLevelTracker

Attributes

id[R]

Public Class Methods

new(event) click to toggle source
# File lib/test_prof/event_prof/monitor.rb, line 22
def initialize(event)
  super
  @id = :"event_prof_monitor_#{event}"
  Thread.current[id] = 0
end

Public Instance Methods

track() { || ... } click to toggle source
# File lib/test_prof/event_prof/monitor.rb, line 28
def track
  Thread.current[id] += 1
  res = nil
  begin
    res =
      if Thread.current[id] == 1
        super { yield }
      else
        yield
      end
  ensure
    Thread.current[id] -= 1
  end
  res
end