Sha256: 9e55b25bc8c4c34ac1bcafea93ac8ab100c92c6e624328929acae43917a5daf0

Contents?: true

Size: 1.12 KB

Versions: 13

Compression:

Stored size: 1.12 KB

Contents

# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/components/logger'

module Contrast
  module Agent
    # Base class for threads that do async processing
    class WorkerThread
      include Contrast::Components::Logger::InstanceMethods

      def initialize
        @_thread = nil
      end

      def running?
        !!@_thread&.alive?
      end

      def stop!
        return unless running?
        return unless @_thread

        Thread.kill(@_thread)
        @_thread = nil
      end

      # Most threads, we always want to start. Some may be controlled by feature guards though, so we need to check.
      #
      # @return [Boolean]
      def attempt_to_start?
        true
      end

      def clean_properties
        logger.debug("Cleaning PROPERTIES_HASH size: #{ Contrast::Agent::Assess::Tracker::PROPERTIES_HASH.size }")
        Contrast::Agent::Assess::Tracker.cleanup!
        logger.debug("Cleaned PROPERTIES_HASH size: #{ Contrast::Agent::Assess::Tracker::PROPERTIES_HASH.size }")
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
contrast-agent-6.11.0 lib/contrast/agent/worker_thread.rb
contrast-agent-6.10.0 lib/contrast/agent/worker_thread.rb
contrast-agent-6.9.0 lib/contrast/agent/worker_thread.rb
contrast-agent-6.8.0 lib/contrast/agent/worker_thread.rb
contrast-agent-6.7.0 lib/contrast/agent/worker_thread.rb
contrast-agent-6.6.5 lib/contrast/agent/worker_thread.rb
contrast-agent-6.6.4 lib/contrast/agent/worker_thread.rb
contrast-agent-6.6.3 lib/contrast/agent/worker_thread.rb
contrast-agent-6.6.2 lib/contrast/agent/worker_thread.rb
contrast-agent-6.6.1 lib/contrast/agent/worker_thread.rb
contrast-agent-6.6.0 lib/contrast/agent/worker_thread.rb
contrast-agent-6.5.1 lib/contrast/agent/worker_thread.rb
contrast-agent-6.5.0 lib/contrast/agent/worker_thread.rb