Module: Aidp::Concurrency

Defined in:
lib/aidp/concurrency.rb,
lib/aidp/concurrency/exec.rb,
lib/aidp/concurrency/wait.rb,
lib/aidp/concurrency/backoff.rb

Overview

Concurrency utilities for deterministic waiting, retry/backoff, and executor management.

This module provides standardized primitives to replace arbitrary sleep() calls with proper synchronization, timeouts, and event-based coordination using concurrent-ruby.

Examples:

Wait for a condition

Concurrency::Wait.until(timeout: 30) { File.exist?(path) }

Retry with backoff

Concurrency::Backoff.retry(max_attempts: 5) { risky_call() }

Get a named executor

pool = Concurrency::Exec.pool(name: :io_pool, size: 10)
future = Concurrent::Promises.future_on(pool) { fetch_data() }

Defined Under Namespace

Modules: Backoff, Exec, Wait Classes: Configuration, Error, MaxAttemptsError, TimeoutError

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



49
50
51
# File 'lib/aidp/concurrency.rb', line 49

def configuration
  @configuration ||= Configuration.new
end

.loggerObject



57
58
59
60
61
62
63
64
65
66
# File 'lib/aidp/concurrency.rb', line 57

def logger
  @logger ||= if defined?(Aidp.logger)
    Aidp.logger
  elsif defined?(Rails)
    Rails.logger
  else
    require "logger"
    Logger.new($stdout)
  end
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



53
54
55
# File 'lib/aidp/concurrency.rb', line 53

def configure
  yield(configuration)
end