Parallel ruby的并行 多线程处理插件

阅读更多
  有多个cpu的话希望提升性能,可以参考。之前听Rails envy就有点印象
用法:
#i -> 0..number_of_your_cpus
results = Parallel.in_processes do |i|
  expensive_computation(data[i])
end

#i -> 0..4
results = Parallel.in_processes(4) do |i|
  expensive_computation(data[i])
end

#same with threads (no speedup through multiple cpus, but speedup for blocking operations)
results = Parallel.in_threads(4) do |i|
  blocking_computation(data[i])
end

git地址: http://github.com/grosser/parallel/tree/master

你可能感兴趣的:(多线程,Ruby,Rails,Git)