Class: Iudex::HTTP::Test::ConcurrentCounter
- Inherits:
-
Object
- Object
- Iudex::HTTP::Test::ConcurrentCounter
- Defined in:
- lib/iudex-http-test/test_app.rb
Instance Method Summary collapse
- #count ⇒ Object
- #enter ⇒ Object
- #exit ⇒ Object
-
#initialize ⇒ ConcurrentCounter
constructor
A new instance of ConcurrentCounter.
- #sync(&block) ⇒ Object
Constructor Details
#initialize ⇒ ConcurrentCounter
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
#count ⇒ Object
71 72 73 |
# File 'lib/iudex-http-test/test_app.rb', line 71 def count sync { @count } end |
#enter ⇒ Object
63 64 65 |
# File 'lib/iudex-http-test/test_app.rb', line 63 def enter sync { @count += 1 } end |
#exit ⇒ Object
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 |