Class: Iudex::HTTP::Test::ConcurrentCounter

Inherits:
Object
  • Object
show all
Defined in:
lib/iudex-http-test/test_app.rb

Instance Method Summary collapse

Constructor Details

#initializeConcurrentCounter

Returns a new instance of ConcurrentCounter.



54
55
56
57
# File 'lib/iudex-http-test/test_app.rb', line 54

def initialize
  @lock = Mutex.new
  @count = 0
end

Instance Method Details

#countObject



71
72
73
# File 'lib/iudex-http-test/test_app.rb', line 71

def count
  sync { @count }
end

#enterObject



63
64
65
# File 'lib/iudex-http-test/test_app.rb', line 63

def enter
  sync { @count += 1 }
end

#exitObject



67
68
69
# File 'lib/iudex-http-test/test_app.rb', line 67

def exit
  sync { @count -= 1 }
end

#sync(&block) ⇒ Object



59
60
61
# File 'lib/iudex-http-test/test_app.rb', line 59

def sync( &block )
  @lock.synchronize( &block )
end