barney 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,5 +1,15 @@
1
1
  2011-04-23 Robert Gleeson <rob@flowof.info>
2
2
 
3
+ * lib/barney.rb README.md ChangeLog:
4
+ Release 0.10.1
5
+
6
+ * lib/barney/share.rb:
7
+ Fix a bug where Barney::Share#history could return unordered/incorrect data
8
+ when subprocesses are spawned in parallel.
9
+
10
+ * lib/barney/share.rb:
11
+ Release 0.10.0
12
+
3
13
  * lib/barney/share.rb:
4
14
  Fix a bug where Barney::Share#share could return nil.
5
15
  If there were no duplicates in @variables, `nil` would be returned.
data/README.md CHANGED
@@ -84,12 +84,12 @@ Documentation
84
84
  **API**
85
85
 
86
86
  * [master (git)](http://rubydoc.info/github/robgleeson/barney/master/)
87
+ * [0.10.1](http://rubydoc.info/gems/barney/0.10.1/)
87
88
  * [0.10.0](http://rubydoc.info/gems/barney/0.10.0/)
88
89
  * [0.9.1](http://rubydoc.info/gems/barney/0.9.1/)
89
90
  * [0.9.0](http://rubydoc.info/gems/barney/0.9.0/)
90
91
  * [0.8.1](http://rubydoc.info/gems/barney/0.8.1/)
91
92
  * [0.8.0](http://rubydoc.info/gems/barney/0.8.0/)
92
- * [0.7.0](http://rubydoc.info/gems/barney/0.7.0)
93
93
  * …
94
94
 
95
95
 
data/lib/barney/share.rb CHANGED
@@ -77,18 +77,22 @@ module Barney
77
77
  # @return [Fixnum] Returns the Process ID(PID) of the spawned child process.
78
78
  def fork &blk
79
79
  raise ArgumentError, "A block or Proc object is expected" unless block_given?
80
- spawn_pipes
80
+
81
+ tmp_streams = Array.new @variables.size do |index|
82
+ StreamPair.new @variables[index], *IO.pipe
83
+ end
81
84
 
82
85
  @context = blk.binding
83
86
  @pid = Kernel.fork do
84
87
  blk.call
85
- @streams.each do |stream|
88
+ tmp_streams.each do |stream|
86
89
  stream.in.close
87
90
  stream.out.write Marshal.dump(eval("#{stream.variable}", @context))
88
91
  stream.out.close
89
92
  end
90
93
  end
91
94
 
95
+ @streams.push *tmp_streams
92
96
  @pid
93
97
  end
94
98
 
@@ -110,17 +114,6 @@ module Barney
110
114
  end
111
115
  alias_method :sync, :synchronize
112
116
 
113
- private
114
-
115
- # Manages the creation of pipes used for cross-process communcation.
116
- # @return [void]
117
- # @api private
118
- def spawn_pipes
119
- @variables.each do |variable|
120
- @streams.push StreamPair.new(variable, *IO.pipe)
121
- end
122
- end
123
-
124
117
  end
125
118
 
126
119
  end
data/lib/barney.rb CHANGED
@@ -2,7 +2,7 @@ require 'barney/share'
2
2
 
3
3
  module Barney
4
4
 
5
- VERSION = '0.10.0'
5
+ VERSION = '0.10.1'
6
6
  @proxy = Barney::Share.new
7
7
 
8
8
  class << self
@@ -13,7 +13,29 @@ describe Barney::Share do
13
13
  Barney::Share.new.fork
14
14
  end
15
15
  end
16
-
16
+
17
+ it 'should not cause #history to return bad/incorrect data.' do
18
+ 50.times do
19
+ str = ""
20
+ pids = []
21
+
22
+ obj = Barney::Share.new
23
+ obj.share :str
24
+
25
+ %w(r u b y).each do |letter|
26
+ pids << obj.fork do
27
+ str << letter
28
+ end
29
+ end
30
+
31
+ pids.each { |pid| Process.wait pid }
32
+ obj.sync
33
+
34
+ str = obj.history.map(&:value).join
35
+ assert_equal "ruby", str
36
+ end
37
+ end
38
+
17
39
  end
18
40
 
19
41
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: barney
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.10.0
5
+ version: 0.10.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Robert Gleeson
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-25 00:00:00 +01:00
13
+ date: 2011-05-03 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency