async 1.4.0 → 1.4.1
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 +4 -4
- data/lib/async/reactor.rb +22 -7
- data/lib/async/version.rb +1 -1
- data/spec/async/performance_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44eb7af07e00729f3e1ecc10e98cd7cda6d09a117a9d3f62e33a22d5fc7068b4
|
4
|
+
data.tar.gz: 115e88de10b11bb887b3a17c1c82f29d9ea1d082e13ac874e5311c37cfc7cdaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a48d12ecd04670b4d552772bf882c190230aa15cb1946f0558d46f3bf9b50d321d160128d2667db57b6531af26ca01a68457754c40b9aa91135bfb63d36e983
|
7
|
+
data.tar.gz: b56e6e3e0ccf58fd47f70f99209badf9c536430ffe3d8fac7f4f6694670c06d2e4861e61f87d4767822a01264b1b0ad5fede8ab23e8d35a9a4d5cdc8ba6cc537
|
data/lib/async/reactor.rb
CHANGED
@@ -131,6 +131,10 @@ module Async
|
|
131
131
|
Fiber.yield
|
132
132
|
end
|
133
133
|
|
134
|
+
def finished?
|
135
|
+
super && @ready.empty?
|
136
|
+
end
|
137
|
+
|
134
138
|
# Run the reactor until either all tasks complete or {#stop} is invoked.
|
135
139
|
# Proxies arguments to {#async} immediately before entering the loop.
|
136
140
|
def run(*args, &block)
|
@@ -142,22 +146,33 @@ module Async
|
|
142
146
|
initial_task = async(*args, &block) if block_given?
|
143
147
|
|
144
148
|
@timers.wait do |interval|
|
149
|
+
if @ready.any?
|
150
|
+
@ready.each do |fiber|
|
151
|
+
fiber.resume if fiber.alive?
|
152
|
+
end
|
153
|
+
|
154
|
+
@ready.clear
|
155
|
+
|
156
|
+
# The above tasks may schedule, cancel or affect timers in some way. We need to compute a new wait interval for the blocking selector call below:
|
157
|
+
interval = @timers.wait_interval
|
158
|
+
end
|
159
|
+
|
145
160
|
# - nil: no timers
|
146
161
|
# - -ve: timers expired already
|
147
162
|
# - 0: timers ready to fire
|
148
163
|
# - +ve: timers waiting to fire
|
149
|
-
|
164
|
+
if interval && interval < 0
|
165
|
+
interval = 0
|
166
|
+
end
|
150
167
|
|
151
168
|
# Async.logger.debug{"[#{self} Pre] Updating #{@children.count} children..."}
|
152
169
|
# As timeouts may have been updated, and caused fibers to complete, we should check this.
|
153
170
|
|
154
|
-
@ready.each do |fiber|
|
155
|
-
fiber.resume if fiber.alive?
|
156
|
-
end; @ready.clear
|
157
|
-
|
158
171
|
# If there is nothing to do, then finish:
|
159
172
|
# Async.logger.debug{"[#{self}] @children.empty? = #{@children.empty?} && interval #{interval.inspect}"}
|
160
|
-
|
173
|
+
if !interval && self.finished?
|
174
|
+
return initial_task
|
175
|
+
end
|
161
176
|
|
162
177
|
# Async.logger.debug{"Selecting with #{@children.count} fibers interval = #{interval.inspect}..."}
|
163
178
|
if monitors = @selector.select(interval)
|
@@ -171,7 +186,7 @@ module Async
|
|
171
186
|
|
172
187
|
return initial_task
|
173
188
|
ensure
|
174
|
-
Async.logger.debug{"
|
189
|
+
Async.logger.debug(self) {"Exiting run-loop because #{$! ? $!.inspect : 'finished'}."}
|
175
190
|
@stopped = true
|
176
191
|
end
|
177
192
|
|
data/lib/async/version.rb
CHANGED
@@ -7,7 +7,7 @@ RSpec.describe Async::Wrapper do
|
|
7
7
|
let(:input) {described_class.new(pipe.first)}
|
8
8
|
let(:output) {described_class.new(pipe.last)}
|
9
9
|
|
10
|
-
it "should be fast to
|
10
|
+
it "should be fast to wait until readable" do
|
11
11
|
Benchmark.ips do |x|
|
12
12
|
x.report('Wrapper#wait_readable') do |repeats|
|
13
13
|
Async::Reactor.run do |task|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nio4r
|