class Concurrent::ImmediateExecutor
@note Intended for use primarily in testing and debugging.
during testing because it makes all operations deterministic.
that thread until the operation is complete. This can be very beneficial
it immediately runs every ‘#post` operation on the current thread, blocking
This executor service exists mainly for testing an debugging. When used
received and no two operations can be performed simultaneously.
blocking as necessary. Operations are performed in the order they are
An executor service which runs all operations on the current thread,
def <<(task)
def <<(task) post(&task) self end
def initialize
def initialize @stopped = Concurrent::Event.new end
def post(*args, &task)
def post(*args, &task) raise ArgumentError.new('no block given') unless block_given? return false unless running? task.call(*args) true end
def running?
def running? ! shutdown? end
def shutdown
def shutdown @stopped.set true end
def shutdown?
def shutdown? @stopped.set? end
def shuttingdown?
def shuttingdown? false end
def wait_for_termination(timeout = nil)
def wait_for_termination(timeout = nil) @stopped.wait(timeout) end