in-parallel 0.1.6 → 0.1.7

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40ad2577f36e54c5587299b0d14d6ef77b3c4e29
4
- data.tar.gz: 17952b28df96dbc02a21deefee815f4d01419aac
3
+ metadata.gz: 96b4326e2eed1c0b8fb2a99ff7c353ea2b78ea05
4
+ data.tar.gz: 421617914e2609c3b8705cff7f49c50393d2d600
5
5
  SHA512:
6
- metadata.gz: 7a9d29ad97abb4d9ca344c8d4d5d3a8fdf795e51e45c656cb2aadc65cbb3f86998be65066c723408bff7d0e7d89072a069b871bc300f1741f8c65e058c35ed3c
7
- data.tar.gz: f0b0fb02ef1ffbf220fee8aef49fdb71b93ea028747dd15a297d85cbb6b760aa9ea6d508d7f69265c8d683c7b1441dc944ed76f36e9af4d983af073d376ea649
6
+ metadata.gz: 707985cd17daa5dcf0de02b5135f1fc596d0b6009f0fc538fe42815d58565cdcf3c9a0db08a955d587a3986bab9c00de4ccff71cd0823c3fe7ee0cc5954bfc70
7
+ data.tar.gz: bfc404a413b43ce5c4780c2efa79b0fc056d0586db2e794357cf9dd04588032021be21f1e9bac3c330b3523bf43d01d907db0d30196bf8668bab60e3d28f075b
@@ -1,3 +1,3 @@
1
1
  module InParallel
2
- VERSION = Version = '0.1.6'
2
+ VERSION = Version = '0.1.7'
3
3
  end
data/lib/in_parallel.rb CHANGED
@@ -40,6 +40,8 @@ module InParallel
40
40
  # Private method to lookup results from the results_map and replace the
41
41
  # temp values with actual return values
42
42
  def self.result_lookup(proxy_obj, target_obj, results_map)
43
+ target_obj = eval('self', target_obj)
44
+ proxy_obj ||= target_obj
43
45
  vars = (proxy_obj.instance_variables)
44
46
  results = []
45
47
  results_map.keys.each { |tmp_result|
@@ -76,7 +78,7 @@ module InParallel
76
78
  Process.detach(@@process_infos.last[:pid])
77
79
  @@process_infos.pop
78
80
  else
79
- @@background_objs << {:proxy => proxy, :target => eval("self", block.binding)}
81
+ @@background_objs << {:proxy => proxy, :target => block.binding}
80
82
  return process_infos.last[:tmp_result]
81
83
  end
82
84
  return
@@ -154,11 +156,12 @@ module InParallel
154
156
  # pass in the 'self' from the block.binding which is the instance of the class
155
157
  # that contains the initial binding call.
156
158
  # This gives us access to the local and instance variables from that context.
157
- results = result_lookup(proxy, eval("self", binding), results_map) if proxy && binding
159
+ results = result_lookup(proxy, binding, results_map) if binding
158
160
 
159
161
  @@background_objs.each {|obj|
160
162
  results = results.concat result_lookup(obj[:proxy], obj[:target], results_map)
161
163
  }
164
+ @@background_objs.clear
162
165
 
163
166
  return results
164
167
  end
@@ -13,11 +13,11 @@ module Enumerable
13
13
  if Process.respond_to?(:fork) && count > 1
14
14
  identifier ||= "#{caller_locations[0]}"
15
15
  each do |item|
16
- out = InParallel._execute_in_parallel(method_sym) {block.call(item)}
17
- puts "'each_in_parallel' forked process for '#{method_sym}' - PID = '#{out[:pid]}'\n"
16
+ out = InParallel::InParallelExecutor._execute_in_parallel(identifier) {block.call(item)}
17
+ puts "'each_in_parallel' forked process for '#{identifier}' - PID = '#{out[:pid]}'\n"
18
18
  end
19
19
  # return the array of values, no need to look up from the map.
20
- return ::InParallelExecutor.wait_for_processes(nil, block.binding)
20
+ return InParallel::InParallelExecutor.wait_for_processes(nil, block.binding)
21
21
  end
22
22
  puts 'Warning: Fork is not supported on this OS, executing block normally' unless Process.respond_to? :fork
23
23
  block.call
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: in-parallel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - samwoods1