Skip to content

Commit fb5277a

Browse files
committed
Remove useless condition check
Since threads count is already guaranteed to be less or equal than max_active_threads in thread_pool.rb:line 113, there is no need to double check. Not to mention that this will cause a race condition on the JRuby platform, as noted in 5ac9df0. Removing the conditional check will also reduce lock acquisitions and improve overall efficiency. In the original commit 1737459, this check was essential. However, after subsequent changes, it seems no one performed a careful review of this logic.
1 parent 0fdacef commit fb5277a

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

lib/rake/thread_pool.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,13 @@ def process_queue_item #:nodoc:
108108
false
109109
end
110110

111-
def safe_thread_count
112-
@threads_mon.synchronize do
113-
@threads.count
114-
end
115-
end
116-
117111
def start_thread # :nodoc:
118112
@threads_mon.synchronize do
119113
next unless @threads.count < @max_active_threads
120114

121115
t = Thread.new do
122116
begin
123-
while safe_thread_count <= @max_active_threads
117+
loop do
124118
break unless process_queue_item
125119
end
126120
ensure

0 commit comments

Comments
 (0)