README.md in pmap-1.0.2 vs README.md in pmap-1.1.0

- old
+ new

@@ -1,13 +1,14 @@ pmap [![Build Status](https://secure.travis-ci.org/bruceadams/pmap.png)](http://travis-ci.org/bruceadams/pmap) [![Code Climate](https://codeclimate.com/github/bruceadams/pmap.png)](https://codeclimate.com/github/bruceadams/pmap) ==== -This Ruby gem adds two methods to any Enumerable (notably including +This Ruby gem adds three methods to any Enumerable (notably including any Array). The two added methods are: * _pmap_ parallel map * _peach_ parallel each +* _peach_with_index_ parallel each_with_index Threading in Ruby has limitations. ---------------------------------- Matz Ruby 1.8.* uses _green_ threads. All Ruby threads are run within @@ -30,15 +31,10 @@ multiple HTTP requests in parallel. Issuing those requests in separate Ruby threads means the requests will be issued very quickly, well before the responses start coming back. As responses come back, they will be processed as they arrive. -Thread Count ----------------- - -The thread count defaults to 64 and is set based on `$pmap_default_thread_count`. - Example ------- Suppose that we have a function get_quote that calls out to a stock quote service to get a current stock price. The response time for @@ -52,5 +48,21 @@ # Replacing "map" with "pmap" speeds it up. # This will take about half a second; # however long the single slowest response took. stock_quotes = stock_symbols.pmap {|s| get_quote(s)} + +Thread Count +------------ + +The thread count defaults to 64 and is set based on `$pmap_default_thread_count`. + +You can also set the thread count per call by passing it as an argument to the `pmap` and `peach` methods. + + # Use the default thread count (64) + (1..128).peach { |i| sleep 1 } # Takes 2 seconds + + # Use a thread count of 128 + (1..128).peach(128) { |i| sleep 1 } # Takes 1 second + + # Use a thread count of 2 + (1..128).peach(2) { |i| sleep 1 } # Takes 64 seconds