Class: Contrast::Agent::WorkerThread

Inherits:
Object
  • Object
show all
Includes:
Components::Logger::InstanceMethods
Defined in:
lib/contrast/agent/thread/worker_thread.rb

Overview

Base class for threads that do async processing

Instance Method Summary collapse

Methods included from Components::Logger::InstanceMethods

#cef_logger, #logger

Constructor Details

#initialize ⇒ WorkerThread



12
13
14
# File 'lib/contrast/agent/thread/worker_thread.rb', line 12

def initialize
  @_thread = nil
end

Instance Method Details

#attempt_to_start? ⇒ Boolean

Most threads, we always want to start. Some may be controlled by feature guards though, so we need to check.



31
32
33
# File 'lib/contrast/agent/thread/worker_thread.rb', line 31

def attempt_to_start?
  Contrast::AGENT.enabled?
end

#clean_properties ⇒ Object



35
36
37
38
39
# File 'lib/contrast/agent/thread/worker_thread.rb', line 35

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

#running? ⇒ Boolean



16
17
18
# File 'lib/contrast/agent/thread/worker_thread.rb', line 16

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

#stop! ⇒ Object



20
21
22
23
24
25
26
# File 'lib/contrast/agent/thread/worker_thread.rb', line 20

def stop!
  return unless running?
  return unless @_thread

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