lib/cukeforker/worker_queue.rb in cukeforker-0.2.1 vs lib/cukeforker/worker_queue.rb in cukeforker-0.2.2
- old
+ new
@@ -1,12 +1,13 @@
module CukeForker
class WorkerQueue
include Observable
- def initialize(max, delay)
+ def initialize(max, delay, fail_fast=false)
@max = max
@delay = delay
+ @fail_fast = fail_fast
if @max < 0
raise ArgumentError, "max workers cannot be negative, got #{@max.inspect}"
end
@@ -118,9 +119,15 @@
end
def finish(worker)
@running.delete worker
@finished << worker
+
+ if @fail_fast && worker.failed?
+ @pending.clear
+ @running.each { |w| w.kill }
+ @running.clear
+ end
fire :on_worker_finished, worker
end
def fire(*args)