Class: Hoss::ChildDurations::Durations Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hoss/child_durations.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDurations

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Durations.



40
41
42
43
44
45
# File 'lib/hoss/child_durations.rb', line 40

def initialize
  @nesting_level = 0
  @start = nil
  @duration = 0
  @mutex = Mutex.new
end

Instance Attribute Details

#durationObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



47
48
49
# File 'lib/hoss/child_durations.rb', line 47

def duration
  @duration
end

Instance Method Details

#startObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



49
50
51
52
53
54
# File 'lib/hoss/child_durations.rb', line 49

def start
  @mutex.synchronize do
    @nesting_level += 1
    @start = Util.micros if @nesting_level == 1
  end
end

#stopObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



56
57
58
59
60
61
# File 'lib/hoss/child_durations.rb', line 56

def stop
  @mutex.synchronize do
    @nesting_level -= 1
    @duration = (Util.micros - @start) if @nesting_level == 0
  end
end