Sha256: 890bc1ebd4e60e62425aec30909b03db322098e454fb095c95a590025af0d652

Contents?: true

Size: 850 Bytes

Versions: 37

Compression:

Stored size: 850 Bytes

Contents

# frozen_string_literal: true

module GoodJob
  # Provides methods for determining the status of the
  # current job execution thread. This is useful for determining
  # whether to continue processing a job or to shut down gracefully.
  module ThreadStatus
    extend ActiveSupport::Concern

    class_methods do
      # Whether the current job execution thread is in a running state.
      # @return [Boolean]
      def current_thread_running?
        scheduler = Thread.current[:good_job_scheduler]
        scheduler ? scheduler.running? : true
      end

      # Whether the current job execution thread is shutting down
      # (the opposite of running).
      # @return [Boolean]
      def current_thread_shutting_down?
        scheduler = Thread.current[:good_job_scheduler]
        scheduler && !scheduler.running?
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
good_job-4.8.2 lib/good_job/thread_status.rb
good_job-4.8.1 lib/good_job/thread_status.rb
good_job-4.8.0 lib/good_job/thread_status.rb
good_job-4.7.0 lib/good_job/thread_status.rb
good_job-4.6.0 lib/good_job/thread_status.rb
good_job-4.5.1 lib/good_job/thread_status.rb
good_job-4.5.0 lib/good_job/thread_status.rb
good_job-4.4.2 lib/good_job/thread_status.rb
good_job-4.4.1 lib/good_job/thread_status.rb
good_job-4.4.0 lib/good_job/thread_status.rb
good_job-4.3.0 lib/good_job/thread_status.rb
good_job-4.2.1 lib/good_job/thread_status.rb
good_job-4.2.0 lib/good_job/thread_status.rb
good_job-4.1.1 lib/good_job/thread_status.rb
good_job-4.1.0 lib/good_job/thread_status.rb
good_job-3.99.1 lib/good_job/thread_status.rb
good_job-4.0.3 lib/good_job/thread_status.rb
good_job-4.0.2 lib/good_job/thread_status.rb
good_job-4.0.1 lib/good_job/thread_status.rb
good_job-4.0.0 lib/good_job/thread_status.rb