Module: Rubu::TrailRun

Included in:
Step, Trail
Defined in:
lib/rubu.rb

Overview

Trail execution methods.

Instance Method Summary (collapse)

Instance Method Details

- (Object) parallel_run



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
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
# File 'lib/rubu.rb', line 193

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

- (Object) serial_run



180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/rubu.rb', line 180

def serial_run
    @subs.each do |sub|
        sub.run
        if sub.status == :error
            @status = :error
            @errmsg = sub.errmsg
            break
        end
    end

    self
end