Skip to content

Commit 2205415

Browse files
committed
Simplify the code a bit inside ensure_threads_running!
1 parent 95ea335 commit 2205415

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/kafka/async_producer.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,8 @@ def ensure_threads_running!
155155
return if worker_thread_alive? && timer_thread_alive?
156156

157157
@thread_mutex.synchronize do
158-
@worker_thread = nil unless worker_thread_alive?
159-
@worker_thread ||= Thread.new { @worker.run }
160-
161-
@timer_thread = nil unless timer_thread_alive?
162-
@timer_thread ||= Thread.new { @timer.run }
158+
@worker_thread = Thread.new { @worker.run } unless worker_thread_alive?
159+
@timer_thread = Thread.new { @timer.run } unless timer_thread_alive?
163160
end
164161
end
165162

0 commit comments

Comments
 (0)