Sha256: 0281cee8bb4bc2e78ab0345133fae5ca0211e6467e6efd0f7e27c8cc61125a39

Contents?: true

Size: 662 Bytes

Versions: 46

Compression:

Stored size: 662 Bytes

Contents

#--
# Copyright (c) 2008, 2009 Jeremy Hinegardner
# All rights reserved.  See LICENSE and/or COPYING for details.
#++

require 'thread'

module Hitimes
  #
  # 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.
  #
  class MutexedStats < Stats
    def initialize
      @mutex = Mutex.new
    end

    # call-seq:
    #   mutex_stat.update( val ) -> nil
    # 
    # Update the running stats with the new value in a threadsafe manner.
    #
    def update( value )
      @mutex.synchronize do
        super( value )
      end
    end
  end
end


Version data entries

46 entries across 44 versions & 4 rubygems

Version Path
hitimes-1.3.1-x64-mingw32 lib/hitimes/mutexed_stats.rb
hitimes-1.3.1-x86-mingw32 lib/hitimes/mutexed_stats.rb
hitimes-1.3.1-java lib/hitimes/mutexed_stats.rb
hitimes-1.3.1 lib/hitimes/mutexed_stats.rb
hitimes-1.3.0-x64-mingw32 lib/hitimes/mutexed_stats.rb
hitimes-1.3.0-x86-mingw32 lib/hitimes/mutexed_stats.rb
hitimes-1.3.0-java lib/hitimes/mutexed_stats.rb
hitimes-1.3.0 lib/hitimes/mutexed_stats.rb
hitimes-1.2.6-x86-mingw32 lib/hitimes/mutexed_stats.rb
hitimes-1.2.6-java lib/hitimes/mutexed_stats.rb
hitimes-1.2.6 lib/hitimes/mutexed_stats.rb
hitimes-1.2.5-java lib/hitimes/mutexed_stats.rb
hitimes-1.2.5-x86-mingw32 lib/hitimes/mutexed_stats.rb
hitimes-1.2.5 lib/hitimes/mutexed_stats.rb
hitimes-1.2.4-java lib/hitimes/mutexed_stats.rb
hitimes-1.2.4-x86-mingw32 lib/hitimes/mutexed_stats.rb
hitimes-1.2.4 lib/hitimes/mutexed_stats.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/hitimes-1.2.2/lib/hitimes/mutexed_stats.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/hitimes-1.2.2/lib/hitimes/mutexed_stats.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/hitimes-1.2.2/lib/hitimes/mutexed_stats.rb