Replace ThreadingHelper wait loop with functional CyclicBarrier (#36508)

pull/36526/head
Ben Sheldon [he/him] 2 weeks ago committed by GitHub
parent 82483ed8b0
commit 843c43c97a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,17 +1,18 @@
# frozen_string_literal: true
require 'concurrent/atomic/cyclic_barrier'
module ThreadingHelpers
def multi_threaded_execution(thread_count)
wait_for_start = true
barrier = Concurrent::CyclicBarrier.new(thread_count)
threads = Array.new(thread_count) do
Thread.new do
true while wait_for_start
barrier.wait
yield
end
end
wait_for_start = false
threads.each(&:join)
end
end

Loading…
Cancel
Save