Sha256: 95357db686f43340c86a254a4ba3010bca74d31a62ee594898cc77523a96f0ec

Contents?: true

Size: 892 Bytes

Versions: 2

Compression:

Stored size: 892 Bytes

Contents

# encoding: utf-8

module TuneMyGc
  module Spies
    class Base
      def initialize
        @processed = 0
        @limit = nil
      end

      def install
        raise NotImplementedError
      end

      def uninstall
        raise NotImplementedError
      end

      def check_uninstall
        if ENV["RUBY_GC_TUNE"] && ENV["RUBY_GC_TUNE"] != ""
          @limit ||= parse_gc_tune
          @processed += 1
          if @processed == @limit
            uninstall
            TuneMyGc.log "kamikaze after #{@processed} of #{@limit} units of work"
            TuneMyGc.interposer.kamikaze
          elsif ENV['RUBY_GC_TUNE_VERBOSE']
            TuneMyGc.log "logged #{@processed} of #{@limit} units of work"
          end
        end
      end

      private
      def parse_gc_tune
        Integer(ENV["RUBY_GC_TUNE"])
      rescue ArgumentError
        1
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tunemygc-1.0.71 lib/tunemygc/spies/base.rb
tunemygc-1.0.69 lib/tunemygc/spies/base.rb