Skip to content

Instantly share code, notes, and snippets.

/sample.rb Secret

Created November 13, 2016 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/ce3fdb19a8abc235cd6d5454ae3cd66d to your computer and use it in GitHub Desktop.
Save anonymous/ce3fdb19a8abc235cd6d5454ae3cd66d to your computer and use it in GitHub Desktop.
def self.set_threads(num_threads)
# puts "Creating thread pool with #{num_threads} threads"
@thread_pool = Concurrent::FixedThreadPool.new(num_threads)
end
...
for index in 0..(samples.size - samples_to_mix) do
futures.push Concurrent::Future.new(
# arguments for Future construction
{
# @thread_pool must already be set
:executor => @thread_pool,
# these args will be passed to the Proc upon execution
# failure to properly pass the args will result in the Proc sharing
# values between multple Futures
:args => [index, samples_to_mix, samples[index]]
}
) { |index, samples_to_mix, sample|
MixtureMaker.mix_and_count_recursive( \
index + 1, \
samples_to_mix - 1, \
sample
)
}.execute
end
futures.each_with_index { |future, index|
temp_allele_counts_by_locus, temp_max_alleles_total, temp_different_maxes, temp_dropin_total = future.value
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment