sync-defer 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGES
2
2
 
3
+ ## sync-defer 0.9.4 -- 2012-03-21
4
+
5
+ * Fixed a bug that where there's an exception in multiple computations,
6
+ the fiber should not be resumed twice or more times. This bug is caught
7
+ by JRuby.
8
+
9
+ * `SyncDefer.defer` should also return only one value if there's only one
10
+ computation.
11
+
3
12
  ## sync-defer 0.9.3 -- 2012-03-20
4
13
 
5
14
  * Also work without a reactor in the generic interface: `SyncDefer.defer`,
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ desc 'Generate gemspec'
8
8
  task 'gem:spec' do
9
9
  Gemgem.spec = Gemgem.create do |s|
10
10
  s.name = 'sync-defer'
11
- s.version = '0.9.3'
11
+ s.version = '0.9.4'
12
12
 
13
13
  %w[].each{ |g| s.add_runtime_dependency(g) }
14
14
  end
@@ -45,11 +45,11 @@ module EventMachine::SyncDefer
45
45
  },
46
46
  lambda{ |result|
47
47
  if exception
48
- fiber.resume(nil, exception)
48
+ fiber.resume(nil, exception) if fiber.alive?
49
49
  else
50
50
  results[index] = result
51
51
  fiber.resume(results.sort.map(&:last), nil) if
52
- results.size == funcs.size
52
+ results.size == funcs.size && fiber.alive?
53
53
  end
54
54
  })
55
55
  end
@@ -22,7 +22,11 @@ module SyncDefer
22
22
  "Only cool.io and eventmachine are supported.")
23
23
  $stderr.puts(" Called from: #{caller.last(5).inspect}")
24
24
  args << block if block_given?
25
- args.map(&:call)
25
+ if args.size == 1
26
+ args.first.call
27
+ else
28
+ args.map(&:call)
29
+ end
26
30
  end
27
31
  end
28
32
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "sync-defer"
5
- s.version = "0.9.3"
5
+ s.version = "0.9.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Lin Jen-Shin (godfat)"]
9
- s.date = "2012-03-20"
9
+ s.date = "2012-03-21"
10
10
  s.description = "Synchronous deferred operations with fibers (coroutines)"
11
11
  s.email = ["godfat (XD) godfat.org"]
12
12
  s.files = [
@@ -94,7 +94,7 @@ begin
94
94
  EM.stop
95
95
  }.resume
96
96
  }
97
- result.inspect.should == [0, 1, 2, 3].inspect
97
+ result.inspect.should.eql [0, 1, 2, 3].inspect
98
98
  end
99
99
 
100
100
  should 'defer_multi' do
@@ -107,7 +107,7 @@ begin
107
107
  EM.stop
108
108
  }.resume
109
109
  }
110
- result.inspect.should == [0, 1, 2, 3].inspect
110
+ result.inspect.should.eql [0, 1, 2, 3].inspect
111
111
  end
112
112
 
113
113
  should 'raise the exception' do
@@ -141,3 +141,20 @@ begin
141
141
  rescue LoadError => e
142
142
  puts "eventmachine is not installed, skipping: #{e}"
143
143
  end
144
+
145
+ describe SyncDefer do
146
+ after do
147
+ RR.verify
148
+ end
149
+
150
+ should 'also work without a reactor, but print a warning' do
151
+ mock($stderr).puts(is_a(String)).times(2)
152
+ SyncDefer.defer{ 123 }.should.eql 123
153
+ end
154
+
155
+ should 'multiple computations' do
156
+ mock($stderr).puts(is_a(String)).times(2)
157
+ SyncDefer.defer(lambda{1}, lambda{2}){ 3 }.
158
+ inspect.should.eql [1, 2, 3].inspect
159
+ end
160
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sync-defer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-20 00:00:00.000000000 Z
12
+ date: 2012-03-21 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Synchronous deferred operations with fibers (coroutines)
15
15
  email: