Class: GoodJob::Scheduler::ThreadPoolExecutor

Inherits:
Concurrent::ThreadPoolExecutor
  • Object
show all
Defined in:
lib/good_job/scheduler.rb

Overview

Custom sub-class of Concurrent::ThreadPoolExecutor to add additional worker status.

Instance Method Summary collapse

Instance Method Details

#ready_worker_countInteger

Number of inactive threads available to execute tasks. github.com/ruby-concurrency/concurrent-ruby/issues/684#issuecomment-427594437

Returns:

  • (Integer)


171
172
173
174
175
176
177
178
# File 'lib/good_job/scheduler.rb', line 171

def ready_worker_count
  synchronize do
    workers_still_to_be_created = @max_length - @pool.length
    workers_created_but_waiting = @ready.length

    workers_still_to_be_created + workers_created_but_waiting
  end
end