core-async 0.4.0 → 0.5.0
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/CHANGELOG.md +9 -0
- data/lib/core/async/collection.rb +10 -1
- data/lib/core/async/enumerator.rb +12 -13
- data/lib/core/async/version.rb +1 -1
- data/lib/is/async.rb +14 -6
- 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: 5449a66653642c9fa6f96c2a968bda754e31aefdee4c207d1e3a02e18e7e7dcb
|
4
|
+
data.tar.gz: bc9e2ae806089f3a64cb3a3fa15d97505c5be54c0ca455577ddf3f6b1806f73b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fe6d3f541fd066a958453573f027a70321f0176e3db0b1e3afdb414841bcb8d7367414ccc1aa6ae06b97437ef2fc299fee761ab88661470d69bd7cffd2d9c88
|
7
|
+
data.tar.gz: a4786ac589bbb949c78ca6832e27b49abe79ed36b2b401529b0a56443404165e665d6f28aecdeeb9d1543e2f7e7c8ffba4ad05219fe5775e74d89fde750d2f9e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## [v0.5.0](https://github.com/metabahn/corerb/releases/tag/2021-03-26)
|
2
|
+
|
3
|
+
*released on 2021-03-26*
|
4
|
+
|
5
|
+
* `chg` [#25](https://github.com/metabahn/corerb/pull/25) Privatize async behavior ([bryanp](https://github.com/bryanp))
|
6
|
+
* `add` [#24](https://github.com/metabahn/corerb/pull/24) Add Is::Async#cancel ([bryanp](https://github.com/bryanp))
|
7
|
+
* `fix` [#23](https://github.com/metabahn/corerb/pull/23) Improve control flow during async enumeration / collection building ([bryanp](https://github.com/bryanp))
|
8
|
+
* `fix` [#22](https://github.com/metabahn/corerb/pull/22) Expose errors that occur when building a collection ([bryanp](https://github.com/bryanp))
|
9
|
+
|
1
10
|
## [v0.4.0](https://github.com/metabahn/corerb/releases/tag/2021-03-17.1)
|
2
11
|
|
3
12
|
*released on 2021-03-17*
|
@@ -12,17 +12,26 @@ module Core
|
|
12
12
|
#
|
13
13
|
def build(object)
|
14
14
|
aware do
|
15
|
+
errored, stopped = false
|
16
|
+
|
15
17
|
values = object.map { |value|
|
18
|
+
break if errored || stopped
|
19
|
+
|
16
20
|
async do
|
17
21
|
if block_given?
|
18
22
|
yield value
|
19
23
|
else
|
20
24
|
value
|
21
25
|
end
|
26
|
+
rescue LocalJumpError
|
27
|
+
stopped = true
|
28
|
+
rescue => error
|
29
|
+
errored = true
|
30
|
+
raise error
|
22
31
|
end
|
23
32
|
}
|
24
33
|
|
25
|
-
new(values)
|
34
|
+
new(values) if values
|
26
35
|
end
|
27
36
|
end
|
28
37
|
end
|
@@ -24,20 +24,19 @@ module Core
|
|
24
24
|
end
|
25
25
|
|
26
26
|
await do
|
27
|
-
errored = false
|
27
|
+
errored, stopped = false
|
28
|
+
|
28
29
|
@object.each do |value|
|
29
|
-
break if errored
|
30
|
-
|
31
|
-
async
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
}
|
30
|
+
break if errored || stopped
|
31
|
+
|
32
|
+
async do
|
33
|
+
yield value
|
34
|
+
rescue LocalJumpError
|
35
|
+
stopped = true
|
36
|
+
rescue => error
|
37
|
+
errored = true
|
38
|
+
raise error
|
39
|
+
end
|
41
40
|
end
|
42
41
|
end
|
43
42
|
end
|
data/lib/core/async/version.rb
CHANGED
data/lib/is/async.rb
CHANGED
@@ -29,7 +29,7 @@ module Is
|
|
29
29
|
|
30
30
|
# [public] Call behavior synchronously but within an async context, waiting on the result.
|
31
31
|
#
|
32
|
-
def await
|
32
|
+
private def await
|
33
33
|
if (task = ::Async::Task.current?)
|
34
34
|
reference = task.async { |current|
|
35
35
|
begin
|
@@ -51,7 +51,7 @@ module Is
|
|
51
51
|
|
52
52
|
# [public] Call behavior within an async context without additional nesting.
|
53
53
|
#
|
54
|
-
def aware
|
54
|
+
private def aware
|
55
55
|
if ::Async::Task.current?
|
56
56
|
yield
|
57
57
|
else
|
@@ -63,7 +63,7 @@ module Is
|
|
63
63
|
|
64
64
|
# [public] Sleeps for `seconds` in a proper async context.
|
65
65
|
#
|
66
|
-
def sleep(seconds)
|
66
|
+
private def sleep(seconds)
|
67
67
|
internal_await do |task|
|
68
68
|
task.sleep(seconds)
|
69
69
|
end
|
@@ -73,7 +73,7 @@ module Is
|
|
73
73
|
#
|
74
74
|
# Raises `Core::Async::Timeout` if execution exceeds `seconds`.
|
75
75
|
#
|
76
|
-
def timeout(seconds, &block)
|
76
|
+
private def timeout(seconds, &block)
|
77
77
|
internal_await do |task|
|
78
78
|
if seconds && seconds > 0
|
79
79
|
task.with_timeout(seconds, Core::Async::Timeout) do
|
@@ -87,15 +87,23 @@ module Is
|
|
87
87
|
|
88
88
|
# [public] Yields control to allow other fibers to execute.
|
89
89
|
#
|
90
|
-
def defer
|
90
|
+
private def defer
|
91
91
|
if (task = ::Async::Task.current?)
|
92
92
|
task.yield
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
+
# [public] Cancels the current async behavior if in progress.
|
97
|
+
#
|
98
|
+
private def cancel
|
99
|
+
if (task = ::Async::Task.current?)
|
100
|
+
task.stop
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
96
104
|
# [public] Resolves a potential future to a final result.
|
97
105
|
#
|
98
|
-
def resolve(value)
|
106
|
+
private def resolve(value)
|
99
107
|
case value
|
100
108
|
when Core::Async::Future
|
101
109
|
value.result
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: core-async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Powell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|