lib/cukeforker/worker_queue.rb in cukeforker-0.2.0 vs lib/cukeforker/worker_queue.rb in cukeforker-0.2.1

- old
+ new

@@ -1,16 +1,21 @@ module CukeForker class WorkerQueue include Observable - def initialize(max) + def initialize(max, delay) @max = max + @delay = delay if @max < 0 raise ArgumentError, "max workers cannot be negative, got #{@max.inspect}" end + unless @delay.kind_of?(Numeric) + raise ArgumentError, "delay must be Numeric, got #{@delay.inspect}:#{@delay.class}" + end + @pending = [] @running = [] @finished = [] end @@ -106,9 +111,11 @@ def start(worker) fire :on_worker_starting, worker worker.start @running << worker + + sleep @delay end def finish(worker) @running.delete worker @finished << worker