Ruby concurrency extensions
FutureProof provides concurrency extensions for Ruby.
Add this line to your application's Gemfile:
gem 'future_proof'
And then execute:
$ bundle
Or install it yourself as:
$ gem install future_proof
future = FutureProof::Future.new { |a, b| a + b }
future.call(1, 2) # => executes in a thread
future.value # => returns value when ready
thread_pool = FutureProof::ThreadPool.new(5)
10.times do |i|
thread_pool.submit i, i + 1 do |a, b|
a + b
end
end
thread_pool.perform # executes 10 procs in 5 threads
thread_pool.values # releases threads and returns values
If exception happens inside a thread it doesn't affect the whole process. Exception is raised when accessing specific value:
thread_pool.values[3] # => raises exception
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)