Class: CDC::Parallel::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/cdc/parallel/configuration.rb

Overview

Immutable configuration for Ractor runtimes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size: Etc.nprocessors, timeout: nil) ⇒ Configuration

Returns a new instance of Configuration.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
# 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?

  super
  ::Ractor.make_shareable(self)
end

Instance Attribute Details

#sizeInteger

Returns worker count.

Returns:

  • (Integer)

    worker count.



11
12
13
14
15
16
17
18
19
# 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?

    super
    ::Ractor.make_shareable(self)
  end
end

#timeoutFloat?

Returns optional wait timeout in seconds.

Returns:

  • (Float, nil)

    optional wait timeout in seconds.



11
12
13
14
15
16
17
18
19
# 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?

    super
    ::Ractor.make_shareable(self)
  end
end