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 ns_make_executor_runnable end
Public Instance Methods
kill()
click to toggle source
# File lib/concurrent/executor/java_executor_service.rb, line 52 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 26 def post(*args, &task) raise ArgumentError.new('no block given') unless block_given? return handle_fallback(*args, &task) unless running? @executor.submit_runnable 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 44 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 35 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_make_executor_runnable()
click to toggle source
# File lib/concurrent/executor/java_executor_service.rb, line 78 def ns_make_executor_runnable if !defined?(@executor.submit_runnable) @executor.class.class_eval do java_alias :submit_runnable, :submit, [java.lang.Runnable.java_class] end end end
ns_running?()
click to toggle source
# File lib/concurrent/executor/java_executor_service.rb, line 62 def ns_running? !(ns_shuttingdown? || ns_shutdown?) end
ns_shutdown?()
click to toggle source
# File lib/concurrent/executor/java_executor_service.rb, line 74 def ns_shutdown? @executor.isShutdown || @executor.isTerminated end
ns_shuttingdown?()
click to toggle source
# File lib/concurrent/executor/java_executor_service.rb, line 66 def ns_shuttingdown? if @executor.respond_to? :isTerminating @executor.isTerminating else false end end