class Concurrent::JavaExecutorService
@!visibility private
@!macro abstract_executor_service_public_api
def initialize(*args, &block)
def initialize(*args, &block) super end
def kill
def kill synchronize do self.ns_auto_terminate = false @executor.shutdownNow nil end end
def ns_running?
def ns_running? !(ns_shuttingdown? || ns_shutdown?) end
def ns_shutdown?
def ns_shutdown? @executor.isShutdown || @executor.isTerminated end
def ns_shuttingdown?
def ns_shuttingdown? if @executor.respond_to? :isTerminating @executor.isTerminating else false end end
def post(*args, &task)
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
def shutdown
def shutdown synchronize do self.ns_auto_terminate = false @executor.shutdown nil end end
def wait_for_termination(timeout = nil)
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