Class: Roast::SystemCogs::Map::Config
- Inherits:
-
Cog::Config
- Object
- Cog::Config
- Roast::SystemCogs::Map::Config
- Defined in:
- lib/roast/system_cogs/map.rb
Overview
Configuration for the ‘map` cog
Instance Attribute Summary
Attributes inherited from Cog::Config
Instance Method Summary collapse
-
#no_parallel! ⇒ Object
Configure the cog to execute iterations serially (one at a time).
-
#parallel(value) ⇒ Object
Configure the cog to execute iterations in parallel with a maximum number of concurrent tasks.
-
#parallel! ⇒ Object
Configure the cog to execute iterations in parallel with unlimited concurrency.
-
#valid_parallel! ⇒ Object
Get the validated, configured parallelism limit.
-
#validate! ⇒ Object
Validate the configuration.
Methods inherited from Cog::Config
#[], #[]=, #abort_on_failure!, #abort_on_failure?, #async!, #async?, field, #initialize, #merge, #no_abort_on_failure!, #no_async!, #use_current_working_directory!, #valid_working_directory, #working_directory
Constructor Details
This class inherits a constructor from Roast::Cog::Config
Instance Method Details
#no_parallel! ⇒ Object
Configure the cog to execute iterations serially (one at a time)
This is the default behavior. Iterations will run sequentially in order.
#### See Also
-
‘parallel`
-
‘parallel!`
: () -> void
63 64 65 |
# File 'lib/roast/system_cogs/map.rb', line 63 def no_parallel! @values[:parallel] = 1 end |
#parallel(value) ⇒ Object
Configure the cog to execute iterations in parallel with a maximum number of concurrent tasks
Pass ‘0` to enable unlimited parallelism (no concurrency limit). Pass a positive integer to limit the number of iterations that can run concurrently.
Default: serial execution (equivalent to ‘parallel(1)`)
#### See Also
-
‘parallel!`
-
‘no_parallel!`
: (Integer) -> void
35 36 37 38 |
# File 'lib/roast/system_cogs/map.rb', line 35 def parallel(value) # treat 0 as unlimited parallelism @values[:parallel] = value > 0 ? value : nil end |
#parallel! ⇒ Object
Configure the cog to execute iterations in parallel with unlimited concurrency
This removes any limit on the number of iterations that can run concurrently. All iterations will start simultaneously.
#### See Also
-
‘parallel`
-
‘no_parallel!`
: () -> void
50 51 52 |
# File 'lib/roast/system_cogs/map.rb', line 50 def parallel! @values[:parallel] = nil end |
#valid_parallel! ⇒ Object
Get the validated, configured parallelism limit
Returns ‘nil` for unlimited parallelism, or an `Integer` for the maximum number of concurrent iterations. This method will raise an `InvalidConfigError` if the parallelism value is negative.
#### See Also
-
‘parallel`
-
‘parallel!`
-
‘no_parallel!`
: () -> Integer?
86 87 88 89 90 91 92 |
# File 'lib/roast/system_cogs/map.rb', line 86 def valid_parallel! parallel = @values.fetch(:parallel, 1) return if parallel.nil? raise InvalidConfigError, "'parallel' must be >= 0 if specified" if parallel < 0 parallel end |
#validate! ⇒ Object
Validate the configuration
: () -> void
70 71 72 |
# File 'lib/roast/system_cogs/map.rb', line 70 def validate! valid_parallel! end |