core-async 0.5.0 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5449a66653642c9fa6f96c2a968bda754e31aefdee4c207d1e3a02e18e7e7dcb
4
- data.tar.gz: bc9e2ae806089f3a64cb3a3fa15d97505c5be54c0ca455577ddf3f6b1806f73b
3
+ metadata.gz: 1475f225e7a3c63b06f254003ff34f377ab467aa26bb086903ba85db0c16d6ec
4
+ data.tar.gz: 013b3220d6e1d6b051524c57e551880a064aad3dcace1c40110f60793c18c9a1
5
5
  SHA512:
6
- metadata.gz: 7fe6d3f541fd066a958453573f027a70321f0176e3db0b1e3afdb414841bcb8d7367414ccc1aa6ae06b97437ef2fc299fee761ab88661470d69bd7cffd2d9c88
7
- data.tar.gz: a4786ac589bbb949c78ca6832e27b49abe79ed36b2b401529b0a56443404165e665d6f28aecdeeb9d1543e2f7e7c8ffba4ad05219fe5775e74d89fde750d2f9e
6
+ metadata.gz: 2b7a37821649338dd1336d587e3c49d1df817729470c01c98cbbeb77c50e07ee7163aead7eabb5ef37bf288f0a00589d705933f16c1114656ebd023deb81e24b
7
+ data.tar.gz: f71a80e8efe333555b5d436e8f2d0cde7450754059bbf70d2266507b0bed1c6fb505c1c3a09ef29cf748566ef9d6100d0efea92a4e3f578a502205b3a2e6fdf7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ ## [v0.8.0](https://github.com/metabahn/corerb/releases/tag/2021-07-15)
2
+
3
+ *released on 2021-07-15*
4
+
5
+ * `add` [#50](https://github.com/metabahn/corerb/pull/50) Make all async objects inspectable ([bryanp](https://github.com/bryanp))
6
+
7
+ ## [v0.7.0](https://github.com/metabahn/corerb/releases/tag/2021-07-07)
8
+
9
+ *released on 2021-07-07*
10
+
11
+ * `chg` [#38](https://github.com/metabahn/corerb/pull/38) Drop Ruby 2.6 support from core-async ([bryanp](https://github.com/bryanp))
12
+
13
+ ## [v0.6.1](https://github.com/metabahn/corerb/releases/tag/2021-05-20.1)
14
+
15
+ *released on 2021-05-20*
16
+
17
+ * `fix` [#29](https://github.com/metabahn/corerb/pull/29) Actually disable the console logger ([bryanp](https://github.com/bryanp))
18
+
19
+ ## [v0.6.0](https://github.com/metabahn/corerb/releases/tag/2021-05-20)
20
+
21
+ *released on 2021-05-20*
22
+
23
+ * `fix` [#28](https://github.com/metabahn/corerb/pull/28) Turn off the console logger in all contexts ([bryanp](https://github.com/bryanp))
24
+ * `chg` [#27](https://github.com/metabahn/corerb/pull/27) Propagate throws from async contexts ([bryanp](https://github.com/bryanp))
25
+
1
26
  ## [v0.5.0](https://github.com/metabahn/corerb/releases/tag/2021-03-26)
2
27
 
3
28
  *released on 2021-03-26*
@@ -1,4 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "async"
4
- Console.logger.off!
4
+
5
+ # Turn the console logger off everywhere.
6
+ #
7
+ ENV["CONSOLE_LEVEL"] ||= "5"
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "is/inspectable"
4
+
3
5
  require_relative "../../is/async"
4
6
 
5
7
  module Core
@@ -38,6 +40,7 @@ module Core
38
40
 
39
41
  include Enumerable
40
42
  include Is::Async
43
+ include Is::Inspectable
41
44
 
42
45
  def initialize(values = [])
43
46
  unless values.respond_to?(:each)
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "is/inspectable"
4
+
3
5
  require_relative "../../is/async"
4
6
 
5
7
  module Core
@@ -7,6 +9,7 @@ module Core
7
9
  class Enumerator
8
10
  include Enumerable
9
11
  include Is::Async
12
+ include Is::Inspectable
10
13
 
11
14
  def initialize(object)
12
15
  unless object.respond_to?(:each)
@@ -1,10 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "is/inspectable"
4
+
3
5
  module Core
4
6
  module Async
5
7
  # [public] Represents a future result.
6
8
  #
7
9
  class Future
10
+ include Is::Inspectable
11
+ inspects without: [:@task]
12
+
8
13
  def initialize(task)
9
14
  @task = task
10
15
  @error = nil
@@ -40,6 +45,8 @@ module Core
40
45
  wait_all(@task)
41
46
 
42
47
  resolve_value(@task.result)
48
+ rescue UncaughtThrowError => error
49
+ throw error.tag, error.value
43
50
  rescue => error
44
51
  @error = error
45
52
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "is/inspectable"
4
+
3
5
  require_relative "../../is/async"
4
6
 
5
7
  module Core
@@ -8,6 +10,8 @@ module Core
8
10
  #
9
11
  class Reactor
10
12
  include Is::Async
13
+ include Is::Inspectable
14
+ inspects without: [:@runnable]
11
15
 
12
16
  class << self
13
17
  # [public] Create a new reactor and immediately run it.
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "is/inspectable"
4
+
3
5
  module Core
4
6
  module Async
5
7
  # [public] Raised when execution times out.
6
8
  #
7
9
  class Timeout < RuntimeError
10
+ include Is::Inspectable
8
11
  end
9
12
  end
10
13
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Core
4
4
  module Async
5
- VERSION = "0.5.0"
5
+ VERSION = "0.8.0"
6
6
 
7
7
  def self.version
8
8
  VERSION
data/lib/is/async.rb CHANGED
@@ -6,7 +6,7 @@ require_relative "../core/async/timeout"
6
6
  require_relative "../core/async/wrapper"
7
7
 
8
8
  module Is
9
- # [public] Makes Ruby objects async-aware.
9
+ # [public] Makes objects async-aware.
10
10
  #
11
11
  module Async
12
12
  # [public] Call behavior asychronously, returning a future.
@@ -47,6 +47,8 @@ module Is
47
47
  }.result
48
48
  }.wait
49
49
  end
50
+ rescue UncaughtThrowError => error
51
+ throw error.tag, error.value
50
52
  end
51
53
 
52
54
  # [public] Call behavior within an async context without additional nesting.
@@ -73,16 +75,24 @@ module Is
73
75
  #
74
76
  # Raises `Core::Async::Timeout` if execution exceeds `seconds`.
75
77
  #
76
- private def timeout(seconds, &block)
78
+ private def timeout(seconds)
77
79
  internal_await do |task|
80
+ timed_task = internal_async {
81
+ yield
82
+ }
83
+
78
84
  if seconds && seconds > 0
79
85
  task.with_timeout(seconds, Core::Async::Timeout) do
80
- yield
86
+ timed_task.wait
81
87
  end
82
88
  else
83
- yield
89
+ timed_task.wait
84
90
  end
91
+ ensure
92
+ timed_task&.stop
85
93
  end
94
+ rescue UncaughtThrowError => error
95
+ throw error.tag, error.value
86
96
  end
87
97
 
88
98
  # [public] Yields control to allow other fibers to execute.
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.5.0
4
+ version: 0.8.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-26 00:00:00.000000000 Z
11
+ date: 2021-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.28'
27
+ - !ruby/object:Gem::Dependency
28
+ name: core-inspect
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.0'
27
41
  description: Makes Ruby objects async-aware.
28
42
  email: bryan@metabahn.com
29
43
  executables: []
@@ -54,14 +68,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
68
  requirements:
55
69
  - - ">="
56
70
  - !ruby/object:Gem::Version
57
- version: 2.5.0
71
+ version: '2.7'
58
72
  required_rubygems_version: !ruby/object:Gem::Requirement
59
73
  requirements:
60
74
  - - ">="
61
75
  - !ruby/object:Gem::Version
62
76
  version: '0'
63
77
  requirements: []
64
- rubygems_version: 3.2.4
78
+ rubygems_version: 3.2.15
65
79
  signing_key:
66
80
  specification_version: 4
67
81
  summary: Makes Ruby objects async-aware.