class Aws::S3::FileDownloader
def download_in_threads(pending, total_size)
def download_in_threads(pending, total_size) threads = [] progress = MultipartProgress.new(pending, total_size, @progress_callback) if @progress_callback @thread_count.times do thread = Thread.new do begin while part = pending.shift if progress part.params[:on_chunk_received] = proc do |_chunk, bytes, total| progress.call(part.part_number, bytes, total) end end resp = @client.get_object(part.params) write(resp) if @on_checksum_validated && resp.checksum_validated @on_checksum_validated.call(resp.checksum_validated, resp) end end nil rescue => error # keep other threads from downloading other parts pending.clear! raise error end end threads << thread end threads.map(&:value).compact end