parallel2 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1 +1,22 @@
1
+ Parrallel2
2
+ ----------
1
3
 
4
+ Parallel#each and Parallel#map are using Celluloid::Future
5
+
6
+ ```ruby
7
+
8
+ require 'parallel2'
9
+
10
+ list = [1,10,2,9,3,8,4,7,5,6]
11
+ Parallel.each(list) do
12
+ sleep i
13
+ puts "#{i} fired!"
14
+ end
15
+
16
+ results = Parallel.map(list) do
17
+ sleep i
18
+ puts "#{i} fired!"
19
+ i * 2
20
+ end
21
+
22
+ ```
@@ -0,0 +1,18 @@
1
+ $:.unshift "lib"
2
+
3
+ require 'parallel2'
4
+
5
+ list = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]
6
+
7
+ Parallel.each(list) do |i|
8
+ sleep i
9
+ puts "#{i} fired!"
10
+ end
11
+
12
+ data = Parallel.map(list) do |i|
13
+ sleep i
14
+ puts "#{i} fired!"
15
+ i
16
+ end
17
+
18
+ p data
@@ -5,18 +5,27 @@ class Parallel
5
5
 
6
6
  def self.each(collection, &block)
7
7
  klass = new(collection, &block)
8
- klass.parallelized_each(&block)
8
+ klass.parallelized_each
9
9
  collection
10
10
  end
11
11
 
12
+ def self.map(collection, &block)
13
+ klass = new(collection, &block)
14
+ klass.parallelized_map
15
+ end
16
+
12
17
  def initialize(collection, &block)
13
18
  @collection = collection
14
19
  @block = block
15
20
  end
16
21
 
17
- def parallelized_each(&block)
22
+ def parallelized_each
18
23
  futures.each(&:value)
19
24
  end
25
+
26
+ def parallelized_map
27
+ futures.map(&:value)
28
+ end
20
29
 
21
30
  def futures
22
31
  @futures ||= @collection.map do |item|
Binary file
@@ -4,9 +4,9 @@ require "rubygems"
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "parallel2"
7
- gem.version = "0.1.0"
7
+ gem.version = "0.2.0"
8
8
  gem.author = "Bryan Goines"
9
- gem.summary = "Parallel #each using Celluloid::Future"
9
+ gem.summary = "Parallel#each and Parallel#map are using Celluloid::Future"
10
10
  gem.email = "bryann83@gmail.com"
11
11
  gem.homepage = "https://github.com/bry4n/parallel2"
12
12
  gem.files = Dir['**/*']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-07 00:00:00.000000000 Z
12
+ date: 2012-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: celluloid
16
- requirement: &70129727674940 !ruby/object:Gem::Requirement
16
+ requirement: &70124090545240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
@@ -21,16 +21,18 @@ dependencies:
21
21
  version: 0.10.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70129727674940
24
+ version_requirements: *70124090545240
25
25
  description:
26
26
  email: bryann83@gmail.com
27
27
  executables: []
28
28
  extensions: []
29
29
  extra_rdoc_files: []
30
30
  files:
31
+ - examples/sleep.rb
31
32
  - Gemfile
32
33
  - lib/parallel2.rb
33
34
  - LICENSE
35
+ - parallel2-0.1.0.gem
34
36
  - parallel2.gemspec
35
37
  - README.md
36
38
  homepage: https://github.com/bry4n/parallel2
@@ -56,5 +58,5 @@ rubyforge_project:
56
58
  rubygems_version: 1.8.11
57
59
  signing_key:
58
60
  specification_version: 3
59
- summary: ! 'Parallel #each using Celluloid::Future'
61
+ summary: Parallel#each and Parallel#map are using Celluloid::Future
60
62
  test_files: []