rake-opt-parallel 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzUxNTFkYmVjY2MwNzQ3YzQ0ODliYzc2NzYwY2QxOGExMjQwNjlkNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTk2ODQ1MjViMGM2MTg3MzlmOGNhMGNlOGZlNDVkODEwMGVkYjExYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzAzMDJjYTUyMDAyMjkzZmRmOTJjNTQxZDgwM2IyOTg5NThlNTM0OWVlNzI5
|
10
|
+
NTJkNDZmOWQyZWY2NjMwY2Y2NjE0YTI4ZGI4YmNmMmUyNWFiNjEyYjQxOTAw
|
11
|
+
ODk1MDJmOWFkMzk0MzlhYWZhYjQwODZjYWIzMWQ5N2Y1NzAwZTY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWU4YWIxMGMyMzE5MGQ4OTFmOTY5NWNjMDUwMmU5ZWQwMjQwZGQxYTc0MzQ4
|
14
|
+
NjgxNjkzMWVlMjM0ODJhNmQzMDllNmI4OTdmODNhN2Q5NzRiM2UwMmNhMDY1
|
15
|
+
MjRiMzMyMjQ0YzM3MGU5MmMwZTEyNjcxMjhhMzNiNjNkN2RhYmE=
|
@@ -8,7 +8,6 @@ module Enumerable
|
|
8
8
|
return self.each {}
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
11
|
def parallel_map(options={}, &block)
|
13
12
|
# Convert options hash to a mash
|
14
13
|
options = ::Hashie::Mash.new(options)
|
@@ -25,6 +24,7 @@ module Enumerable
|
|
25
24
|
thread_count = options.unlimited ? self.size : options.force
|
26
25
|
# Create a seperate thread pool
|
27
26
|
thread_pool = Rake::ThreadPool.new(thread_count-1)
|
27
|
+
thread_pool.add_reference
|
28
28
|
else
|
29
29
|
# Otherwise, use the existing thread pool
|
30
30
|
thread_pool = Rake.application.thread_pool
|
@@ -37,6 +37,13 @@ module Enumerable
|
|
37
37
|
|
38
38
|
# Fulfill all promises
|
39
39
|
promises.reverse_each { |f| f.value }
|
40
|
+
|
41
|
+
# Remove ThreadPool instance references if it's not the main one
|
42
|
+
if thread_pool != Rake.application.thread_pool
|
43
|
+
thread_pool.remove_reference
|
44
|
+
thread_pool = nil
|
45
|
+
end
|
46
|
+
|
40
47
|
return promises.map { |f| f.value }
|
41
48
|
end
|
42
49
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rake/thread_pool'
|
2
|
+
require 'set'
|
3
|
+
|
4
|
+
class Rake::ThreadPool
|
5
|
+
@@instance_collector = Set.new
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def all_instances
|
9
|
+
return @@instance_collector
|
10
|
+
end
|
11
|
+
|
12
|
+
def join_all
|
13
|
+
all_instances.each(&:join)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_reference
|
18
|
+
@@instance_collector << self
|
19
|
+
end
|
20
|
+
|
21
|
+
def remove_reference
|
22
|
+
@@instance_collector.delete(self)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Rake.application.thread_pool.add_reference
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: rake-opt-parallel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
version: !binary |-
|
5
|
-
|
5
|
+
MC4yLjA=
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jon San Miguel
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-05-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/rake/opt/parallel.rb
|
70
70
|
- lib/rake/opt/parallel/patches.rb
|
71
71
|
- lib/rake/opt/parallel/patches/enumerable.rb
|
72
|
+
- lib/rake/opt/parallel/patches/rake/thread_pool.rb
|
72
73
|
- lib/rake/opt/parallel/patches/thread.rb
|
73
74
|
homepage: http://rubygems.org/gems/rake-opt-parallel
|
74
75
|
licenses:
|