FutureProof
FutureProof provides concurrency extensions for Ruby.
Installation
Add this line to your application's Gemfile:
gem 'future_proof'
And then execute:
$ bundle
Or install it yourself as:
$ gem install future_proof
Usage
Future
f = FutureProof::Future.new { |a, b| a + b }
f.call # => executing in a thread
f.value # => returning value when ready
ThreadPool
tp = FutureProof::ThreadPool.new(5)
10.times do |i|
tp.submit(Proc.new { |a, b| a + b }, i, i + 1)
end
tp.perform # executing 10 procs in 5 threads
tp.values # releasing threads and returning values
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request