ione 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ione/future.rb +14 -2
- data/lib/ione/io/base_connection.rb +3 -1
- data/lib/ione/io/io_reactor.rb +5 -2
- data/lib/ione/version.rb +2 -2
- data/spec/ione/future_spec.rb +6 -0
- data/spec/ione/io/connection_common.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 941fc3fd59d15b806854ddd8ff0f30f645ff51bf
|
4
|
+
data.tar.gz: 1b89b672b8b69eda9561138190aed7d35d677538
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f26209edcf366c70ac80a913901f4c6db5a7a15e2e4a9c53e0d73f99b9d1e25e98bd4f0533dc4e88d3ec846abd538b6f80cb9d877ae547091a363121d1a05992
|
7
|
+
data.tar.gz: 6c5565772dd3994caac71ffd2a63cf25f2c595161eeb501928050123c59b5579cf1d5a45ac4a0e585ca15fd9c82b9c7f1253135c2e6f74cf0e9569a89e66d1dc
|
data/lib/ione/future.rb
CHANGED
@@ -226,7 +226,7 @@ module Ione
|
|
226
226
|
# @param [Array<Ione::Future>] futures the futures to combine (this argument
|
227
227
|
# can be a splatted array or a regular array passed as sole argument)
|
228
228
|
# @return [Ione::Future] with a nil value once all futures have succeeded
|
229
|
-
# @since v1.
|
229
|
+
# @since v1.2.1
|
230
230
|
def after(*futures)
|
231
231
|
if futures.size == 1 && (fs = futures.first).is_a?(Enumerable)
|
232
232
|
*futures = *fs
|
@@ -850,7 +850,19 @@ module Ione
|
|
850
850
|
@futures = nil
|
851
851
|
resolve
|
852
852
|
else
|
853
|
-
|
853
|
+
outer = Thread.current
|
854
|
+
looping = more = true
|
855
|
+
while more
|
856
|
+
more = false
|
857
|
+
@futures.pop.on_complete do |v, e|
|
858
|
+
if e || @futures.empty? || !looping || !Thread.current.equal?(outer)
|
859
|
+
await_next(v, e)
|
860
|
+
else
|
861
|
+
more = true
|
862
|
+
end
|
863
|
+
end
|
864
|
+
end
|
865
|
+
looping = false
|
854
866
|
end
|
855
867
|
end
|
856
868
|
end
|
@@ -145,6 +145,7 @@ module Ione
|
|
145
145
|
|
146
146
|
# @private
|
147
147
|
def flush
|
148
|
+
should_close = false
|
148
149
|
if @state == CONNECTED_STATE || @state == DRAINING_STATE
|
149
150
|
@lock.lock
|
150
151
|
begin
|
@@ -154,11 +155,12 @@ module Ione
|
|
154
155
|
end
|
155
156
|
@writable = !@write_buffer.empty?
|
156
157
|
if @state == DRAINING_STATE && !@writable
|
157
|
-
|
158
|
+
should_close = true
|
158
159
|
end
|
159
160
|
ensure
|
160
161
|
@lock.unlock
|
161
162
|
end
|
163
|
+
close if should_close
|
162
164
|
end
|
163
165
|
rescue => e
|
164
166
|
close(e)
|
data/lib/ione/io/io_reactor.rb
CHANGED
@@ -153,20 +153,23 @@ module Ione
|
|
153
153
|
end
|
154
154
|
Thread.start do
|
155
155
|
@started_promise.fulfill(self)
|
156
|
+
error = nil
|
156
157
|
begin
|
157
158
|
while @state == RUNNING_STATE
|
158
159
|
@io_loop.tick
|
159
160
|
@scheduler.tick
|
160
161
|
end
|
162
|
+
rescue => e
|
163
|
+
error = e
|
161
164
|
ensure
|
162
165
|
begin
|
163
166
|
@io_loop.close_sockets
|
164
167
|
@scheduler.cancel_timers
|
165
168
|
@unblocker = nil
|
166
169
|
ensure
|
167
|
-
if
|
170
|
+
if error
|
168
171
|
@state = CRASHED_STATE
|
169
|
-
@stopped_promise.fail(
|
172
|
+
@stopped_promise.fail(error)
|
170
173
|
else
|
171
174
|
@state = STOPPED_STATE
|
172
175
|
@stopped_promise.fulfill(self)
|
data/lib/ione/version.rb
CHANGED
data/spec/ione/future_spec.rb
CHANGED
@@ -1047,6 +1047,12 @@ module Ione
|
|
1047
1047
|
future = Future.after(ff1, ff2, ff3)
|
1048
1048
|
future.value.should be_nil
|
1049
1049
|
end
|
1050
|
+
|
1051
|
+
it 'handles a really long list of futures' do
|
1052
|
+
futures = Array.new(10000, Future.resolved)
|
1053
|
+
future = Future.after(futures)
|
1054
|
+
future.value.should be_nil
|
1055
|
+
end
|
1050
1056
|
end
|
1051
1057
|
end
|
1052
1058
|
|
@@ -90,6 +90,13 @@ shared_examples_for 'a connection' do |options|
|
|
90
90
|
handler.flush
|
91
91
|
f.should be_completed
|
92
92
|
end
|
93
|
+
|
94
|
+
it 'does not attempt to acquire the lock multiple times from the same thread' do
|
95
|
+
handler.write('hello world')
|
96
|
+
f = handler.drain
|
97
|
+
handler.flush
|
98
|
+
expect { f.value }.to_not raise_error
|
99
|
+
end
|
93
100
|
end
|
94
101
|
|
95
102
|
describe '#write/#flush' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ione
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Theo Hultberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Reactive programming framework for Ruby, painless evented IO, futures
|
14
14
|
and an efficient byte buffer
|