class Concurrent::JavaExecutorService

@!macro abstract_executor_service_public_api @!visibility private

Constants

FALLBACK_POLICY_CLASSES

Public Class Methods

new(*args, &block) click to toggle source
Calls superclass method Concurrent::AbstractExecutorService.new
# File lib/concurrent/executor/java_executor_service.rb, line 21
def initialize(*args, &block)
  super
end

Public Instance Methods

kill() click to toggle source
# File lib/concurrent/executor/java_executor_service.rb, line 51
def kill
  synchronize do
    self.ns_auto_terminate = false
    @executor.shutdownNow
    nil
  end
end
post(*args, &task) click to toggle source
# File lib/concurrent/executor/java_executor_service.rb, line 25
def post(*args, &task)
  raise ArgumentError.new('no block given') unless block_given?
  return handle_fallback(*args, &task) unless running?
  @executor.submit Job.new(args, task)
  true
rescue Java::JavaUtilConcurrent::RejectedExecutionException
  raise RejectedExecutionError
end
shutdown() click to toggle source
# File lib/concurrent/executor/java_executor_service.rb, line 43
def shutdown
  synchronize do
    self.ns_auto_terminate = false
    @executor.shutdown
    nil
  end
end
wait_for_termination(timeout = nil) click to toggle source
# File lib/concurrent/executor/java_executor_service.rb, line 34
def wait_for_termination(timeout = nil)
  if timeout.nil?
    ok = @executor.awaitTermination(60, java.util.concurrent.TimeUnit::SECONDS) until ok
    true
  else
    @executor.awaitTermination(1000 * timeout, java.util.concurrent.TimeUnit::MILLISECONDS)
  end
end

Private Instance Methods

ns_running?() click to toggle source
# File lib/concurrent/executor/java_executor_service.rb, line 61
def ns_running?
  !(ns_shuttingdown? || ns_shutdown?)
end
ns_shutdown?() click to toggle source
# File lib/concurrent/executor/java_executor_service.rb, line 73
def ns_shutdown?
  @executor.isShutdown || @executor.isTerminated
end
ns_shuttingdown?() click to toggle source
# File lib/concurrent/executor/java_executor_service.rb, line 65
def ns_shuttingdown?
  if @executor.respond_to? :isTerminating
    @executor.isTerminating
  else
    false
  end
end