Module: Rubu::MoveStyles
Overview
Trail/Step execution styles.
Instance Method Summary collapse
-
#parallel_run ⇒ Object
Run @subs in parallel (unless serial is forced).
-
#serial_run ⇒ Object
Run @subs in sequence.
Instance Method Details
#parallel_run ⇒ Object
Run @subs in parallel (unless serial is forced).
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/rubu.rb', line 211 def parallel_run if Order[ :serial ] serial_run else if Order[ :parmax ] == 0 || @subs.length < Order[ :parmax ] ths = [] @subs.each do |item| ths.push( Thread.new do item.run end ) end ths.each do |th| th.join end else cnt = @subs.length done = 0 while done < cnt incr = Order[ :parmax ] if done >= cnt incr = done - cnt end ths = [] incr.times do |i| item = @subs[ done+i ] ths.push( Thread.new do item.run end ) end ths.each do |th| th.join end done += incr end end @subs.each do |item| if item.status == :error @status = :error @errmsg = item.errmsg break end end self end end |
#serial_run ⇒ Object
Run @subs in sequence.
197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/rubu.rb', line 197 def serial_run @subs.each do |sub| sub.run if sub.status == :error @status = :error @errmsg = sub.errmsg break end end self end |