Class: Metriksd::Timeslice
- Inherits:
-
Object
- Object
- Metriksd::Timeslice
- Defined in:
- lib/metriksd/timeslice.rb
Instance Attribute Summary collapse
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #dirty? ⇒ Boolean
- #flush ⇒ Object
-
#initialize(time) ⇒ Timeslice
constructor
A new instance of Timeslice.
- #push(data) ⇒ Object (also: #<<)
Constructor Details
#initialize(time) ⇒ Timeslice
Returns a new instance of Timeslice.
5 6 7 8 9 10 |
# File 'lib/metriksd/timeslice.rb', line 5 def initialize(time) @time = time @mutex = Mutex.new @dirty = false @records = {} end |
Instance Attribute Details
#time ⇒ Object (readonly)
Returns the value of attribute time.
3 4 5 |
# File 'lib/metriksd/timeslice.rb', line 3 def time @time end |
Instance Method Details
#dirty? ⇒ Boolean
12 13 14 15 16 |
# File 'lib/metriksd/timeslice.rb', line 12 def dirty? @mutex.synchronize do @dirty end end |
#flush ⇒ Object
18 19 20 21 22 23 |
# File 'lib/metriksd/timeslice.rb', line 18 def flush @mutex.synchronize do @dirty = false @records.values end end |
#push(data) ⇒ Object Also known as: <<
25 26 27 28 29 30 |
# File 'lib/metriksd/timeslice.rb', line 25 def push(data) @mutex.synchronize do @records["#{data.client_id}/#{data.name}"] = data @dirty = true end end |