Sha256: 0dfa9e3e2d13e4de9ff346986fdaceede50aa5e4e4b8a2dd676ce721bbea1f5e

Contents?: true

Size: 734 Bytes

Versions: 6

Compression:

Stored size: 734 Bytes

Contents

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

module Contrast
  module Agent
    # Base class for threads that do async processing
    class WorkerThread
      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
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
contrast-agent-6.4.0 lib/contrast/agent/worker_thread.rb
contrast-agent-6.3.0 lib/contrast/agent/worker_thread.rb
contrast-agent-6.2.0 lib/contrast/agent/worker_thread.rb
contrast-agent-6.1.2 lib/contrast/agent/worker_thread.rb
contrast-agent-6.1.1 lib/contrast/agent/worker_thread.rb
contrast-agent-6.1.0 lib/contrast/agent/worker_thread.rb