class Concurrent::RubyExecutorService

@!visibility private
@!macro abstract_executor_service_public_api

def initialize(*args, &block)

def initialize(*args, &block)
  super
  @StopEvent    = Event.new
  @StoppedEvent = Event.new
end

def kill

def kill
  synchronize do
    break if shutdown?
    self.ns_auto_terminate = false
    stop_event.set
    ns_kill_execution
    stopped_event.set
  end
  true
end

def ns_running?

def ns_running?
  !stop_event.set?
end

def ns_shutdown?

def ns_shutdown?
  stopped_event.set?
end

def ns_shutdown_execution

def ns_shutdown_execution
  stopped_event.set
end

def ns_shuttingdown?

def ns_shuttingdown?
  !(ns_running? || ns_shutdown?)
end

def post(*args, &task)

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

def shutdown

def shutdown
  synchronize do
    break unless running?
    self.ns_auto_terminate = false
    stop_event.set
    ns_shutdown_execution
  end
  true
end

def stop_event

def stop_event
  @StopEvent
end

def stopped_event

def stopped_event
  @StoppedEvent
end

def wait_for_termination(timeout = nil)

def wait_for_termination(timeout = nil)
  stopped_event.wait(timeout)
end