Class: Exekutor::Internal::Executor::ThreadPoolExecutor

Inherits:
Concurrent::ThreadPoolExecutor
  • Object
show all
Defined in:
lib/exekutor/internal/executor.rb

Overview

The thread pool to use for executing jobs.

Instance Method Summary collapse

Instance Method Details

#available_threadsInteger

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

Returns:

  • (Integer)


252
253
254
255
256
257
258
259
260
261
262
# File 'lib/exekutor/internal/executor.rb', line 252

def available_threads
  synchronize do
    if Concurrent.on_jruby?
      @executor.getMaximumPoolSize - @executor.getActiveCount
    else
      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
end