Class: NewRelic::Security::Agent::Control::EventCounter
- Inherits:
-
Object
- Object
- NewRelic::Security::Agent::Control::EventCounter
- Defined in:
- lib/newrelic_security/agent/control/event_counter.rb
Instance Method Summary collapse
- #fetch_and_reset_counter ⇒ Object
- #increment ⇒ Object
-
#initialize ⇒ EventCounter
constructor
A new instance of EventCounter.
Constructor Details
#initialize ⇒ EventCounter
Returns a new instance of EventCounter.
7 8 9 10 |
# File 'lib/newrelic_security/agent/control/event_counter.rb', line 7 def initialize @mutex = Mutex.new @counter = 0 end |
Instance Method Details
#fetch_and_reset_counter ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/newrelic_security/agent/control/event_counter.rb', line 18 def fetch_and_reset_counter @mutex.synchronize do old_count = @counter @counter = 0 old_count end end |
#increment ⇒ Object
12 13 14 15 16 |
# File 'lib/newrelic_security/agent/control/event_counter.rb', line 12 def increment @mutex.synchronize do @counter += 1 end end |