class Concurrent::SafeTaskExecutor

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/concurrent-ruby/concurrent/executor/safe_task_executor.rbs

class Concurrent::SafeTaskExecutor < Concurrent::Synchronization::LockableObject
  def execute: (*Array[] args) -> untyped
  def initialize: (Proc task, ?Hash opts) -> void
end

reason - the error risen by the callable if it has been executed with errors, nil otherwise
value - filled by the callable result if it has been executed without errors, nil otherwise
success - indicating if the callable has been executed without errors
A simple utility class that executes a callable and returns and array of three elements:

def execute(*args)

Experimental RBS support (using type sampling data from the type_fusion project).

def execute: (* args) -> untyped

This signature was generated using 2 samples from 1 application.

Returns:
  • (Array) -
def execute(*args)
  success = true
  value   = reason = nil
  synchronize do
    begin
      value   = @task.call(*args)
      success = true
    rescue @exception_class => ex
      reason  = ex
      success = false
    end
  end
  [success, value, reason]
end

def initialize(task, opts = {})

Experimental RBS support (using type sampling data from the type_fusion project).

def initialize: (Proc task, ?rescue_exception | TrueClass opts) -> void

This signature was generated using 4 samples from 2 applications.

def initialize(task, opts = {})
  @task            = task
  @exception_class = opts.fetch(:rescue_exception, false) ? Exception : StandardError
  super() # ensures visibility
end