Class: Isomorfeus::Puppetmaster::Server::Middleware::Counter
- Inherits:
-
Object
- Object
- Isomorfeus::Puppetmaster::Server::Middleware::Counter
- Defined in:
- lib/isomorfeus/puppetmaster/server/middleware.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #decrement ⇒ Object
- #increment ⇒ Object
-
#initialize ⇒ Counter
constructor
A new instance of Counter.
Constructor Details
#initialize ⇒ Counter
Returns a new instance of Counter.
10 11 12 13 |
# File 'lib/isomorfeus/puppetmaster/server/middleware.rb', line 10 def initialize @value = 0 @mutex = Mutex.new end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'lib/isomorfeus/puppetmaster/server/middleware.rb', line 8 def value @value end |
Instance Method Details
#decrement ⇒ Object
19 20 21 |
# File 'lib/isomorfeus/puppetmaster/server/middleware.rb', line 19 def decrement @mutex.synchronize { @value -= 1 } end |
#increment ⇒ Object
15 16 17 |
# File 'lib/isomorfeus/puppetmaster/server/middleware.rb', line 15 def increment @mutex.synchronize { @value += 1 } end |