lib/rocket_job/worker_pool.rb in rocketjob-5.4.1 vs lib/rocket_job/worker_pool.rb in rocketjob-6.0.0.rc1
- old
+ new
@@ -67,16 +67,14 @@
# Wait for all workers to stop.
# Return [true] if all workers stopped
# Return [false] on timeout
def join(timeout = 5)
while (worker = workers.first)
- if worker.join(timeout)
- # Worker thread is dead
- workers.shift
- else
- return false
- end
+ return false unless worker.join(timeout)
+
+ # Worker thread is dead
+ workers.shift
end
true
end
# Returns [Integer] number of workers (threads) that are alive
@@ -89,10 +87,10 @@
end
private
def add_one
- workers << Worker.new(id: next_worker_id, server_name: server_name)
+ workers << ThreadWorker.new(id: next_worker_id, server_name: server_name)
rescue StandardError => e
logger.fatal("Cannot start worker", e)
end
def next_worker_id