Skip to content

Commit

Permalink
threads for the list of large amount of values
Browse files Browse the repository at this point in the history
  • Loading branch information
inutano committed Feb 4, 2014
1 parent 1ebc27e commit da38667
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions sync_and_unzip.rb
@@ -1,4 +1,5 @@
# :)
# using Enumerable#lazy, only for Ruby 2.0

require "rake"

Expand Down Expand Up @@ -30,15 +31,15 @@ def get_files(sym, dir)
end

def unzip_all
threads = []
@unziplist.each do |fastqc_id|
th = Thread.new do
unzip(fastqc_id)
end
threads << th
threads = @unziplist.lazy.map{|id| unzip_task(id) }
threads.each_slice(12).each do |group|
group.each{|t| t.join }
end
threads.each do |th|
th.join
end

def unzip_task(fastqc_id)
Thread.new do
unzip(fastqc_id)
end
end

Expand Down

0 comments on commit da38667

Please sign in to comment.