Sha256: 3ef8dfbca2bfed0a03c22efba6ed2e191b7e383c5183045fbc04fa02f746f528
Contents?: true
Size: 798 Bytes
Versions: 1
Compression:
Stored size: 798 Bytes
Contents
# frozen_string_literal: true # rubocop:disable Style/ClassVars module Bloodbath module Utils module Threading MAX_ACTIVE_THREADS = 10 @@threads = [] @@count = 0 class << self def join_all_threads @@threads.each(&:join).tap do @@count += @@threads.size @@threads = [] end end end at_exit do join_all_threads end def threading thread = Thread.new { yield } to_active_threads(thread) Utils::Threading.join_all_threads if active_threads.size >= MAX_ACTIVE_THREADS thread end private def to_active_threads(thread) @@threads << thread end def active_threads @@threads end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bloodbath-1.1.0 | lib/bloodbath/utils/threading.rb |