async 1.20.0 → 1.20.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/task.rb +8 -2
- data/lib/async/version.rb +1 -1
- data/spec/async/task_spec.rb +2 -2
- 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: 54073e0570fc66e2aedec5657883edaf4aa90ed0e93241c9d2210debf8886441
|
4
|
+
data.tar.gz: 24377adc700b7631969fd299765427ca06208508857eacd5be33b41a137c76c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6a0f47087e557cfb5d2c9ed32b6fe5738ae1f756b99f23c1ab98bf8722ce22d63cddb629cab9225a98ea901b20912c04e267ac94f194ab913e5a511912bb187
|
7
|
+
data.tar.gz: fae19fc4eaad3c8ae827bdf54b2ecacf793c31890bbc47088bc7c01af704cde8eb6f98a7b273706898137d4ca368bcecb15823f8b5f151344e6bada5b12c9adf
|
data/lib/async/task.rb
CHANGED
@@ -90,7 +90,10 @@ module Async
|
|
90
90
|
|
91
91
|
# @attr fiber [Fiber] The fiber which is being used for the execution of this task.
|
92
92
|
attr :fiber
|
93
|
-
|
93
|
+
|
94
|
+
def alive?
|
95
|
+
@fiber&.alive?
|
96
|
+
end
|
94
97
|
|
95
98
|
# @attr status [Symbol] The status of the execution of the fiber, one of `:initialized`, `:running`, `:complete`, `:stopped` or `:failed`.
|
96
99
|
attr :status
|
@@ -142,7 +145,7 @@ module Async
|
|
142
145
|
|
143
146
|
if self.current?
|
144
147
|
raise Stop, "Stopping current fiber!"
|
145
|
-
elsif @fiber
|
148
|
+
elsif @fiber&.alive?
|
146
149
|
@fiber.resume(Stop.new)
|
147
150
|
end
|
148
151
|
end
|
@@ -240,6 +243,9 @@ module Async
|
|
240
243
|
|
241
244
|
# Finish the current task, and all bound bound IO objects.
|
242
245
|
def finish!
|
246
|
+
# Allow the fiber to be recycled.
|
247
|
+
@fiber = nil
|
248
|
+
|
243
249
|
# Attempt to remove this node from the task tree.
|
244
250
|
consume
|
245
251
|
|
data/lib/async/version.rb
CHANGED
data/spec/async/task_spec.rb
CHANGED
@@ -201,8 +201,8 @@ RSpec.describe Async::Task do
|
|
201
201
|
|
202
202
|
parent_task.stop
|
203
203
|
|
204
|
-
expect(parent_task
|
205
|
-
expect(child_task
|
204
|
+
expect(parent_task).to_not be_alive
|
205
|
+
expect(child_task).to_not be_alive
|
206
206
|
end
|
207
207
|
|
208
208
|
it "should not remove running task" do
|
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.20.
|
4
|
+
version: 1.20.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: 2019-07-
|
11
|
+
date: 2019-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nio4r
|