class Atatus::ChildDurations::Durations

@api private

Attributes

duration[R]

Public Class Methods

new() click to toggle source
# File lib/atatus/child_durations.rb, line 40
def initialize
  @nesting_level = 0
  @start = nil
  @duration = 0
  @mutex = Mutex.new
end

Public Instance Methods

start() click to toggle source
# File lib/atatus/child_durations.rb, line 49
def start
  @mutex.synchronize do
    @nesting_level += 1
    @start = Util.micros if @nesting_level == 1
  end
end
stop() click to toggle source
# File lib/atatus/child_durations.rb, line 56
def stop
  @mutex.synchronize do
    @nesting_level -= 1
    @duration = (Util.micros - @start) if @nesting_level == 0
  end
end