You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mastodon/spec/support/threading_helpers.rb

19 lines
353 B
Ruby

# frozen_string_literal: true
require 'concurrent/atomic/cyclic_barrier'
module ThreadingHelpers
def multi_threaded_execution(thread_count)
barrier = Concurrent::CyclicBarrier.new(thread_count)
threads = Array.new(thread_count) do
Thread.new do
barrier.wait
yield
end
end
threads.each(&:join)
end
end