class Concurrent::RubyExecutorService

@!macro abstract_executor_service_public_api @!visibility private

Public Class Methods

new(*args, &block) click to toggle source
Calls superclass method Concurrent::AbstractExecutorService.new
# File lib/concurrent/executor/ruby_executor_service.rb, line 11
def initialize(*args, &block)
  super
  @StopEvent    = Event.new
  @StoppedEvent = Event.new
end

Public Instance Methods

kill() click to toggle source
# 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
shutdown() click to toggle source
# 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
wait_for_termination(timeout = nil) click to toggle source
# File lib/concurrent/executor/ruby_executor_service.rb, line 48
def wait_for_termination(timeout = nil)
  stopped_event.wait(timeout)
end

Private Instance Methods

ns_running?() click to toggle source
# File lib/concurrent/executor/ruby_executor_service.rb, line 66
def ns_running?
  !stop_event.set?
end
ns_shutdown?() click to toggle source
# File lib/concurrent/executor/ruby_executor_service.rb, line 74
def ns_shutdown?
  stopped_event.set?
end
ns_shutdown_execution() click to toggle source
# File lib/concurrent/executor/ruby_executor_service.rb, line 62
def ns_shutdown_execution
  stopped_event.set
end
ns_shuttingdown?() click to toggle source
# File lib/concurrent/executor/ruby_executor_service.rb, line 70
def ns_shuttingdown?
  !(ns_running? || ns_shutdown?)
end
post(*args, &task) click to toggle source
# 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
stop_event() click to toggle source
# File lib/concurrent/executor/ruby_executor_service.rb, line 54
def stop_event
  @StopEvent
end
stopped_event() click to toggle source
# File lib/concurrent/executor/ruby_executor_service.rb, line 58
def stopped_event
  @StoppedEvent
end