Sha256: 8c8f2187703801ae66524896ea66cf549b59d591f06814efa246c1bc45bc8f03
Contents?: true
Size: 1.11 KB
Versions: 13
Compression:
Stored size: 1.11 KB
Contents
module Ecoportal module API module Common module Concerns module Threadable private def new_thread(threads, max: 20, &block) if max == 1 yield return [] end threads.shift.join if threads.count >= max threads << Thread.new(&block) end def mutex(key = :general) require 'thread' key = key.to_sym @mutex ||= {} @mutex[key] ||= Mutex.new end def with_preserved_thread_globals(abort: false, report: true) mutex(:thread_globals).synchronize do aux_thr_aoe = Thread.abort_on_exception aux_thr_roe = Thread.report_on_exception Thread.abort_on_exception = abort Thread.report_on_exception = report yield ensure Thread.abort_on_exception = aux_thr_aoe Thread.report_on_exception = aux_thr_roe end end end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems