Class: TestProf::EventProf::Monitor::TopLevelTracker
- Inherits:
-
BaseTracker
- Object
- BaseTracker
- TestProf::EventProf::Monitor::TopLevelTracker
- Defined in:
- lib/test_prof/event_prof/monitor.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Attributes inherited from BaseTracker
Instance Method Summary collapse
-
#initialize(event) ⇒ TopLevelTracker
constructor
A new instance of TopLevelTracker.
- #track ⇒ Object
Constructor Details
#initialize(event) ⇒ TopLevelTracker
Returns a new instance of TopLevelTracker.
22 23 24 25 26 |
# File 'lib/test_prof/event_prof/monitor.rb', line 22 def initialize(event) super @id = :"event_prof_monitor_#{event}" Thread.current[id] = 0 end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
20 21 22 |
# File 'lib/test_prof/event_prof/monitor.rb', line 20 def id @id end |
Instance Method Details
#track ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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 |