Class: Hitimes::MutexedStats
- Defined in:
- lib/hitimes/mutexed_stats.rb
Overview
MutexedStats is the start of a threadsafe Stats class. Currently, on MRI Ruby the Stats object is already threadsafe, so there is no need to use MutexedStats.
Constant Summary
Constants inherited from Stats
Instance Method Summary collapse
-
#initialize ⇒ MutexedStats
constructor
A new instance of MutexedStats.
-
#update(value) ⇒ Object
call-seq: mutex_stat.update( val ) -> nil.
Methods inherited from Stats
#count, #max, #mean, #min, #rate, #stddev, #sum, #sumsq, #to_hash, #to_json
Constructor Details
#initialize ⇒ MutexedStats
Returns a new instance of MutexedStats.
15 16 17 |
# File 'lib/hitimes/mutexed_stats.rb', line 15 def initialize @mutex = Mutex.new end |
Instance Method Details
#update(value) ⇒ Object
call-seq:
mutex_stat.update( val ) -> nil
Update the running stats with the new value in a threadsafe manner.
24 25 26 27 28 |
# File 'lib/hitimes/mutexed_stats.rb', line 24 def update( value ) @mutex.synchronize do super( value ) end end |