sync-defer 0.9.6 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,10 @@
1
- script: 'git submodule update --init; bundle exec rake test'
1
+ before_install: 'git submodule update --init'
2
+ script: 'ruby -r bundler/setup -S rake test'
3
+
4
+ env:
5
+ - 'RBXOPT=-X19'
6
+
2
7
  rvm:
3
- - 1.9.2
4
8
  - 1.9.3
5
- - rbx-19mode
6
- - jruby-19mode
9
+ - rbx-head
10
+ - jruby-head
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGES
2
2
 
3
+ ## sync-defer 0.9.7 -- 2012-09-14
4
+
5
+ * Do nothing if there's no tasks at all.
6
+
3
7
  ## sync-defer 0.9.6 -- 2012-09-13
4
8
 
5
9
  * Fixed call stacks information in the warning.
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.6'
11
+ s.version = '0.9.7'
12
12
 
13
13
  %w[].each{ |g| s.add_runtime_dependency(g) }
14
14
  end
@@ -8,7 +8,9 @@ module Coolio::SyncDefer
8
8
  loop = args.find { |a| a.kind_of?(Coolio::Loop) }||Coolio::Loop.default
9
9
  funcs = args.reject{ |a| a.kind_of?(Coolio::Loop) }
10
10
  funcs << block if block_given?
11
- if funcs.size == 1
11
+ if funcs.empty?
12
+ return
13
+ elsif funcs.size == 1
12
14
  DeferOne.new(funcs.first, loop).result
13
15
  else
14
16
  DeferMulti.new(funcs, loop).result
@@ -7,7 +7,9 @@ module EventMachine::SyncDefer
7
7
  def defer *funcs, &block
8
8
  fiber = Fiber.current
9
9
  funcs << block if block_given?
10
- if funcs.size == 1
10
+ if funcs.empty?
11
+ return
12
+ elsif funcs.size == 1
11
13
  defer_one(fiber, funcs.first)
12
14
  else
13
15
  defer_multi(fiber, funcs)
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "sync-defer"
5
- s.version = "0.9.6"
5
+ s.version = "0.9.7"
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-09-13"
9
+ s.date = "2012-09-14"
10
10
  s.description = "Synchronous deferred operations with fibers (coroutines)"
11
11
  s.email = ["godfat (XD) godfat.org"]
12
12
  s.files = [
@@ -143,27 +143,43 @@ rescue LoadError => e
143
143
  end
144
144
 
145
145
  describe SyncDefer do
146
- before do mock($stderr).puts(is_a(String)).times(3) end
147
- after do RR.verify end
146
+ describe 'fallback' do
147
+ before do mock($stderr).puts(is_a(String)).times(3) end
148
+ after do RR.verify end
148
149
 
149
- should 'also work without a reactor, but print a warning' do
150
- SyncDefer.defer{ 123 }.should.eql 123
151
- end
150
+ should 'also work without a reactor, but print a warning' do
151
+ SyncDefer.defer{ 123 }.should.eql 123
152
+ end
152
153
 
153
- should 'multiple computations' do
154
- SyncDefer.defer(lambda{1}, lambda{2}){ 3 }.
155
- inspect.should.eql [1, 2, 3].inspect
154
+ should 'multiple computations' do
155
+ SyncDefer.defer(lambda{1}, lambda{2}){ 3 }.
156
+ inspect.should.eql [1, 2, 3].inspect
157
+ end
158
+
159
+ should 'also fallback if there is no fibers in EM' do
160
+ EM.run{ SyncDefer.defer{ 1 }.should.eql 1; EM.stop }
161
+ end if Object.const_defined?(:EventMachine)
162
+
163
+ should 'also fallback if there is no fibers in Coolio' do
164
+ watcher = Coolio::AsyncWatcher.new.attach(Coolio::Loop.default)
165
+ watcher.on_signal{detach}
166
+ SyncDefer.defer{ 1 }.should.eql 1
167
+ watcher.signal
168
+ Coolio::Loop.default.run
169
+ end if Object.const_defined?(:Coolio)
156
170
  end
157
171
 
158
- should 'also fallback if there is no fibers in EM' do
159
- EM.run{ SyncDefer.defer{ 1 }.should.eql 1; EM.stop }
160
- end if Object.const_defined?(:EventMachine)
161
-
162
- should 'also fallback if there is no fibers in Coolio' do
163
- watcher = Coolio::AsyncWatcher.new.attach(Coolio::Loop.default)
164
- watcher.on_signal{detach}
165
- SyncDefer.defer{ 1 }.should.eql 1
166
- watcher.signal
167
- Coolio::Loop.default.run
168
- end if Object.const_defined?(:Coolio)
172
+ describe 'no yield' do
173
+ should 'not yield if there is nothing to do in EM' do
174
+ EM.run{Fiber.new{ SyncDefer.defer.should.eql nil; EM.stop }.resume}
175
+ end if Object.const_defined?(:EventMachine)
176
+
177
+ should 'not yield if there is nothing to do in Coolio' do
178
+ watcher = Coolio::AsyncWatcher.new.attach(Coolio::Loop.default)
179
+ watcher.on_signal{detach}
180
+ Fiber.new{SyncDefer.defer.should.eql nil}.resume
181
+ watcher.signal
182
+ Coolio::Loop.default.run
183
+ end if Object.const_defined?(:Coolio)
184
+ end
169
185
  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.6
4
+ version: 0.9.7
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-09-13 00:00:00.000000000 Z
12
+ date: 2012-09-14 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Synchronous deferred operations with fibers (coroutines)
15
15
  email: