Sha256: c791a2caf4bdcbd3f273e858a979d908c5616b289670c0454f536d7b0067395d

Contents?: true

Size: 602 Bytes

Versions: 4

Compression:

Stored size: 602 Bytes

Contents

# frozen_string_literal: true

module GrpcKit
  class ThreadPool
    class AutoTrimmer
      def initialize(pool, interval: 30)
        @pool = pool
        @interval = interval
        @running = false
      end

      def start!
        @running = true
        @thread = Thread.new do
          loop do
            unless @running
              GrpcKit.logger.debug('Stop AutoTrimer')
              break
            end
            @pool.trim
            sleep @interval
          end
        end
      end

      def stop
        @running = false
        @thread.wakeup
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grpc_kit-0.3.3 lib/grpc_kit/thread_pool/auto_trimmer.rb
grpc_kit-0.3.2 lib/grpc_kit/thread_pool/auto_trimmer.rb
grpc_kit-0.3.1 lib/grpc_kit/thread_pool/auto_trimmer.rb
grpc_kit-0.3.0 lib/grpc_kit/thread_pool/auto_trimmer.rb