mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-30 12:00:13 -05:00
18 lines
317 B
Ruby
18 lines
317 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
module ThreadingHelpers
|
||
|
def multi_threaded_execution(thread_count)
|
||
|
wait_for_start = true
|
||
|
|
||
|
threads = Array.new(thread_count) do
|
||
|
Thread.new do
|
||
|
true while wait_for_start
|
||
|
yield
|
||
|
end
|
||
|
end
|
||
|
|
||
|
wait_for_start = false
|
||
|
threads.each(&:join)
|
||
|
end
|
||
|
end
|