lib/lsperfm/core/stats.rb
# detach_output_reader spawns a thread that will fill in the @stats instance var with tps samples for every seconds
# @stats access is synchronized using the @stats_lock mutex but can be safely used
# once the output reader thread is completed.
detach_output_reader spawns a thread that will fill in the @stats instance var with tps samples for every seconds
detach_output_reader spawns a thread that will fill in the @stats instance var with tps samples for every seconds
def detach_output_reader(io, regex)
      Thread.new(io, regex) do |io, regex|
        i = 0
        @stats = []
        @stats_count = 0
        @stats_lock = Mutex.new
        t = detach_stats_counter
        expect_output(io, regex) do
          i += 1
          @stats_lock.synchronize{@stats_count = i} if (i % REFRESH_COUNT) == 0
        end
        @stats_lock.synchronize{t.kill}
      end
    end
def detach_output_reader ( io , regex ) Thread . new ( io , regex ) do | io , regex | i = 0 @stats = [ ] @stats_count = 0 @stats_lock = Mutex . new t = detach_stats_counter expect_output ( io , regex ) do i += 1 @stats_lock . synchronize { @stats_count = i } if ( i % REFRESH_COUNT ) == 0 end @stats_lock . synchronize { t . kill } end end
detach_output_reader spawns a thread that will fill in the @stats instance var with tps samples for every seconds
detach_output_reader spawns a thread that will fill in the @stats instance var with tps samples for every seconds
# avoid mutex synchronize on every loop cycle, using REFRESH_COUNT = 100 results in # much lower mutex overhead and still provides a good resolution since we are typically # have 2000..100000 tps
io
<not_specific>
regex
<not_specific>
stats
access is synchronized using the @stats_lock mutex but can be safely used once the output reader thread is completed.
access is synchronized using the @stats_lock mutex but can be safely used once the output reader thread is completed .