Module: Bloodbath::Utils::Threading
- Included in:
- Adapters::Rest
- Defined in:
- lib/bloodbath/utils/threading.rb
Constant Summary collapse
- MAX_ACTIVE_THREADS =
10
- @@threads =
[]
- @@count =
0
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.join_all_threads ⇒ Object
12 13 14 15 16 17 |
# File 'lib/bloodbath/utils/threading.rb', line 12 def join_all_threads @@threads.each(&:join).tap do @@count += @@threads.size @@threads = [] end.map(&:value) end |
Instance Method Details
#threading(&block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bloodbath/utils/threading.rb', line 26 def threading(&block) Thread.new(&block).tap do |thread| to_active_threads(thread) if active_threads.size >= MAX_ACTIVE_THREADS Bloodbath::Utils::Verbose.capture("result of threads (reached limit)") do Utils::Threading.join_all_threads end end end end |