@!macro abstract_executor_service_public_api @!visibility private
# File lib/concurrent/executor/ruby_executor_service.rb, line 11 def initialize(*args, &block) super @StopEvent = Event.new @StoppedEvent = Event.new end
# File lib/concurrent/executor/ruby_executor_service.rb, line 37 def kill synchronize do break if shutdown? self.ns_auto_terminate = false stop_event.set ns_kill_execution stopped_event.set end true end
# File lib/concurrent/executor/ruby_executor_service.rb, line 27 def shutdown synchronize do break unless running? self.ns_auto_terminate = false stop_event.set ns_shutdown_execution end true end
# File lib/concurrent/executor/ruby_executor_service.rb, line 48 def wait_for_termination(timeout = nil) stopped_event.wait(timeout) end
# File lib/concurrent/executor/ruby_executor_service.rb, line 66 def ns_running? !stop_event.set? end
# File lib/concurrent/executor/ruby_executor_service.rb, line 74 def ns_shutdown? stopped_event.set? end
# File lib/concurrent/executor/ruby_executor_service.rb, line 62 def ns_shutdown_execution stopped_event.set end
# File lib/concurrent/executor/ruby_executor_service.rb, line 70 def ns_shuttingdown? !(ns_running? || ns_shutdown?) end
# File lib/concurrent/executor/ruby_executor_service.rb, line 17 def post(*args, &task) raise ArgumentError.new('no block given') unless block_given? synchronize do # If the executor is shut down, reject this task return handle_fallback(*args, &task) unless running? ns_execute(*args, &task) true end end
# File lib/concurrent/executor/ruby_executor_service.rb, line 54 def stop_event @StopEvent end
# File lib/concurrent/executor/ruby_executor_service.rb, line 58 def stopped_event @StoppedEvent end