Class: ProconBypassMan::Procon::PerformanceMeasurement::LastBypassAt

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/procon_bypass_man/procon/performance_measurement/last_bypass_at.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLastBypassAt

Returns a new instance of LastBypassAt.



6
7
8
9
# File 'lib/procon_bypass_man/procon/performance_measurement/last_bypass_at.rb', line 6

def initialize
  self.mutex = Mutex.new
  self.last_bypass_at = Time.now
end

Instance Attribute Details

#last_bypass_atObject

Returns the value of attribute last_bypass_at.



4
5
6
# File 'lib/procon_bypass_man/procon/performance_measurement/last_bypass_at.rb', line 4

def last_bypass_at
  @last_bypass_at
end

#mutexObject

Returns the value of attribute mutex.



4
5
6
# File 'lib/procon_bypass_man/procon/performance_measurement/last_bypass_at.rb', line 4

def mutex
  @mutex
end

Class Method Details

.touch(&block) ⇒ Object



11
12
13
14
15
16
# File 'lib/procon_bypass_man/procon/performance_measurement/last_bypass_at.rb', line 11

def self.touch(&block)
  instance.mutex.synchronize do
    block.call(Time.now - instance.last_bypass_at)
    instance.last_bypass_at = Time.now
  end
end