Class: CDC::Parallel::Configuration
- Inherits:
-
Object
- Object
- CDC::Parallel::Configuration
- Defined in:
- lib/cdc/parallel/configuration.rb
Overview
Immutable configuration for Ractor runtimes.
Instance Attribute Summary collapse
-
#size ⇒ Integer
Worker count.
-
#timeout ⇒ Float?
Optional wait timeout in seconds.
Instance Method Summary collapse
-
#initialize(size: Etc.nprocessors, timeout: nil) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(size: Etc.nprocessors, timeout: nil) ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 15 16 17 18 19 20 |
# File 'lib/cdc/parallel/configuration.rb', line 12 def initialize(size: Etc.nprocessors, timeout: nil) raise ArgumentError, "size must be an Integer" unless size.is_a?(Integer) raise ArgumentError, "size must be greater than zero" unless size.positive? raise ArgumentError, "timeout must be numeric" unless timeout.nil? || timeout.is_a?(Numeric) raise ArgumentError, "timeout must be greater than zero" if timeout && !timeout.positive? super ::Ractor.make_shareable(self) end |
Instance Attribute Details
#size ⇒ Integer
Returns worker count.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cdc/parallel/configuration.rb', line 11 class Configuration < Data.define(:size, :timeout) def initialize(size: Etc.nprocessors, timeout: nil) raise ArgumentError, "size must be an Integer" unless size.is_a?(Integer) raise ArgumentError, "size must be greater than zero" unless size.positive? raise ArgumentError, "timeout must be numeric" unless timeout.nil? || timeout.is_a?(Numeric) raise ArgumentError, "timeout must be greater than zero" if timeout && !timeout.positive? super ::Ractor.make_shareable(self) end end |
#timeout ⇒ Float?
Returns optional wait timeout in seconds.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cdc/parallel/configuration.rb', line 11 class Configuration < Data.define(:size, :timeout) def initialize(size: Etc.nprocessors, timeout: nil) raise ArgumentError, "size must be an Integer" unless size.is_a?(Integer) raise ArgumentError, "size must be greater than zero" unless size.positive? raise ArgumentError, "timeout must be numeric" unless timeout.nil? || timeout.is_a?(Numeric) raise ArgumentError, "timeout must be greater than zero" if timeout && !timeout.positive? super ::Ractor.make_shareable(self) end end |