class MultiMeasure::ThreadSafeHash

Public Class Methods

new() click to toggle source
# File lib/multi_measure/thread_safe_hash.rb, line 3
def initialize
  @mutex = Mutex.new
  @hash = {}
end

Public Instance Methods

[](key) click to toggle source
# File lib/multi_measure/thread_safe_hash.rb, line 8
def [](key)
  @mutex.synchronize { @hash[key] }
end
[]=(key, value) click to toggle source
# File lib/multi_measure/thread_safe_hash.rb, line 12
def []=(key, value)
  @mutex.synchronize { @hash[key] = value }
end
each(&block) click to toggle source
# File lib/multi_measure/thread_safe_hash.rb, line 18
def each(&block)
  @mutex.synchronize { @hash.each(&block) }
end
to_normal_hash() click to toggle source
# File lib/multi_measure/thread_safe_hash.rb, line 22
def to_normal_hash
  @mutex.synchronize { @hash.dup }
end