Class: Camayoc::Handlers::Memory
- Inherits:
-
Object
- Object
- Camayoc::Handlers::Memory
- Includes:
- ThreadSafety
- Defined in:
- lib/camayoc/handlers/memory.rb
Constant Summary collapse
- DEFAULT_MAX_EVENTS =
1024
Instance Attribute Summary collapse
-
#max_events ⇒ Object
readonly
Returns the value of attribute max_events.
Instance Method Summary collapse
- #event(ev) ⇒ Object
- #get(stat) ⇒ Object (also: #[])
-
#initialize(options = {}) ⇒ Memory
constructor
A new instance of Memory.
Methods included from ThreadSafety
#synchronize, #thread_safe=, #thread_safe?
Constructor Details
#initialize(options = {}) ⇒ Memory
Returns a new instance of Memory.
11 12 13 14 15 16 |
# File 'lib/camayoc/handlers/memory.rb', line 11 def initialize(={}) @data = {} @max_events = [:max_events].to_i rescue 0 @max_events = DEFAULT_MAX_EVENTS if @max_events <= 0 self.thread_safe = Camayoc.thread_safe? end |
Instance Attribute Details
#max_events ⇒ Object (readonly)
Returns the value of attribute max_events.
9 10 11 |
# File 'lib/camayoc/handlers/memory.rb', line 9 def max_events @max_events end |
Instance Method Details
#event(ev) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/camayoc/handlers/memory.rb', line 18 def event(ev) case ev.type when :count then count(ev) when :timing then timing(ev) when :generic then generic(ev) 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 |