Class: Camayoc::Handlers::Memory
- Inherits:
-
Object
- Object
- Camayoc::Handlers::Memory
- Includes:
- ThreadSafety
- Defined in:
- lib/camayoc/handlers/memory.rb
Instance Method Summary collapse
- #count(event) ⇒ Object
- #get(stat) ⇒ Object (also: #[])
-
#initialize(options = {}) ⇒ Memory
constructor
A new instance of Memory.
- #timing(event) ⇒ Object
Methods included from ThreadSafety
#synchronize, #thread_safe=, #thread_safe?
Constructor Details
#initialize(options = {}) ⇒ Memory
Returns a new instance of Memory.
7 8 9 10 |
# File 'lib/camayoc/handlers/memory.rb', line 7 def initialize(={}) @data = {} self.thread_safe = Camayoc.thread_safe? end |
Instance Method Details
#count(event) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/camayoc/handlers/memory.rb', line 12 def count(event) stat = event.ns_stat synchronize do @data[stat] ||= 0 @data[stat] += event.value end end |
#get(stat) ⇒ Object Also known as: []
26 27 28 29 30 |
# File 'lib/camayoc/handlers/memory.rb', line 26 def get(stat) synchronize do @data[stat] end end |