sync-defer 0.9.6 → 0.9.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.
- data/.travis.yml +8 -4
- data/CHANGES.md +4 -0
- data/Rakefile +1 -1
- data/lib/cool.io/sync-defer.rb +3 -1
- data/lib/eventmachine/sync-defer.rb +3 -1
- data/sync-defer.gemspec +2 -2
- data/test/test_sync-defer.rb +35 -19
- metadata +2 -2
data/.travis.yml
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
|
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-
|
6
|
-
- jruby-
|
9
|
+
- rbx-head
|
10
|
+
- jruby-head
|
data/CHANGES.md
CHANGED
data/Rakefile
CHANGED
data/lib/cool.io/sync-defer.rb
CHANGED
@@ -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
|
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
|
data/sync-defer.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "sync-defer"
|
5
|
-
s.version = "0.9.
|
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-
|
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 = [
|
data/test/test_sync-defer.rb
CHANGED
@@ -143,27 +143,43 @@ rescue LoadError => e
|
|
143
143
|
end
|
144
144
|
|
145
145
|
describe SyncDefer do
|
146
|
-
|
147
|
-
|
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
|
-
|
150
|
-
|
151
|
-
|
150
|
+
should 'also work without a reactor, but print a warning' do
|
151
|
+
SyncDefer.defer{ 123 }.should.eql 123
|
152
|
+
end
|
152
153
|
|
153
|
-
|
154
|
-
|
155
|
-
|
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
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
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.
|
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-
|
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:
|