class Concurrent::RubyExecutorService

@!macro abstract_executor_service_public_api @!visibility private

Public Class Methods

new(*args, &block) click to toggle source
# File lib/concurrent-ruby/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-ruby/concurrent/executor/ruby_executor_service.rb, line 42
def kill
  synchronize do
    break if shutdown?
    stop_event.set
    ns_kill_execution
    stopped_event.set
  end
  true
end
shutdown() click to toggle source
# File lib/concurrent-ruby/concurrent/executor/ruby_executor_service.rb, line 33
def shutdown
  synchronize do
    break unless running?
    stop_event.set
    ns_shutdown_execution
  end
  true
end
wait_for_termination(timeout = nil) click to toggle source
# File lib/concurrent-ruby/concurrent/executor/ruby_executor_service.rb, line 52
def wait_for_termination(timeout = nil)
  stopped_event.wait(timeout)
end

Private Instance Methods

ns_running?() click to toggle source
# File lib/concurrent-ruby/concurrent/executor/ruby_executor_service.rb, line 70
def ns_running?
  !stop_event.set?
end
ns_shutdown?() click to toggle source
# File lib/concurrent-ruby/concurrent/executor/ruby_executor_service.rb, line 78
def ns_shutdown?
  stopped_event.set?
end
ns_shutdown_execution() click to toggle source
# File lib/concurrent-ruby/concurrent/executor/ruby_executor_service.rb, line 66
def ns_shutdown_execution
  stopped_event.set
end
ns_shuttingdown?() click to toggle source
# File lib/concurrent-ruby/concurrent/executor/ruby_executor_service.rb, line 74
def ns_shuttingdown?
  !(ns_running? || ns_shutdown?)
end
post(*args, &task) click to toggle source
# File lib/concurrent-ruby/concurrent/executor/ruby_executor_service.rb, line 17
def post(*args, &task)
  raise ArgumentError.new('no block given') unless block_given?
  deferred_action = synchronize {
    if running?
      ns_execute(*args, &task)
    else
      fallback_action(*args, &task)
    end
  }
  if deferred_action
    deferred_action.call
  else
    true
  end
end
stop_event() click to toggle source
# File lib/concurrent-ruby/concurrent/executor/ruby_executor_service.rb, line 58
def stop_event
  @StopEvent
end
stopped_event() click to toggle source
# File lib/concurrent-ruby/concurrent/executor/ruby_executor_service.rb, line 62
def stopped_event
  @StoppedEvent
end