Parent

Files

Class/Module Index [+]

Quicksearch

Concurrent::ImmediateExecutor

An executor service which runs all operations on the current thread, blocking as necessary. Operations are performed in the order they are received and no two operations can be performed simultaneously.

This executor service exists mainly for testing an debugging. When used it immediately runs every `post` operation on the current thread, blocking that thread until the operation is complete. This can be very beneficial during testing because it makes all operations deterministic.

@note Intended for use primarily in testing and debugging.

Public Class Methods

new() click to toggle source

Creates a new executor

# File lib/concurrent/executor/immediate_executor.rb, line 20
def initialize
  @stopped = Concurrent::Event.new
end

Public Instance Methods

<<(task) click to toggle source

@!macro executor_service_method_left_shift

# File lib/concurrent/executor/immediate_executor.rb, line 33
def <<(task)
  post(&task)
  self
end
kill() click to toggle source
Alias for: shutdown
post(*args, &task) click to toggle source

@!macro executor_service_method_post

# File lib/concurrent/executor/immediate_executor.rb, line 25
def post(*args, &task)
  raise ArgumentError.new('no block given') unless block_given?
  return false unless running?
  task.call(*args)
  true
end
running?() click to toggle source

@!macro executor_service_method_running_question

# File lib/concurrent/executor/immediate_executor.rb, line 39
def running?
  ! shutdown?
end
shutdown() click to toggle source

@!macro executor_service_method_shutdown

# File lib/concurrent/executor/immediate_executor.rb, line 54
def shutdown
  @stopped.set
  true
end
Also aliased as: kill
shutdown?() click to toggle source

@!macro executor_service_method_shutdown_question

# File lib/concurrent/executor/immediate_executor.rb, line 49
def shutdown?
  @stopped.set?
end
shuttingdown?() click to toggle source

@!macro executor_service_method_shuttingdown_question

# File lib/concurrent/executor/immediate_executor.rb, line 44
def shuttingdown?
  false
end
wait_for_termination(timeout = nil) click to toggle source

@!macro executor_service_method_wait_for_termination

# File lib/concurrent/executor/immediate_executor.rb, line 61
def wait_for_termination(timeout = nil)
  @stopped.wait(timeout)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.