core-async 0.3.0 → 0.7.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 +34 -0
 - data/lib/core/async/bootstrap.rb +4 -1
 - data/lib/core/async/collection.rb +10 -1
 - data/lib/core/async/enumerator.rb +12 -13
 - data/lib/core/async/future.rb +4 -4
 - data/lib/core/async/version.rb +1 -1
 - data/lib/is/async.rb +27 -9
 - metadata +4 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 92d18212ad936003747b1db19c40d1e512f59d7cc960fcad17284e4638b3e2ff
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a492ab90f8427994d6a8ad6706a003ce9efbb026530b001a5611c775736952b0
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 97c2580ae213ea539440d95a93975ca8dee74a37c61ba7b7ac5b0a4e77df0b75cb0d4e0eca902ebc14502cae2941c886f852dac7b308c9e43b97488678001184
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 24c45644755815b02fdb2e8dfc3c1d54aeb74dc31355752aaab67733b1be2e666ab521b3e394fb5a3dcc71e6e9dc2bd2688dd1d180e954fb2c8c5ccbfdf0e3ff
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,3 +1,37 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## [v0.7.0](https://github.com/metabahn/corerb/releases/tag/2021-07-07)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            *released on 2021-07-07*
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              * `chg` [#38](https://github.com/metabahn/corerb/pull/38) Drop Ruby 2.6 support from core-async ([bryanp](https://github.com/bryanp))
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            ## [v0.6.1](https://github.com/metabahn/corerb/releases/tag/2021-05-20.1)
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            *released on 2021-05-20*
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              * `fix` [#29](https://github.com/metabahn/corerb/pull/29) Actually disable the console logger ([bryanp](https://github.com/bryanp))
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            ## [v0.6.0](https://github.com/metabahn/corerb/releases/tag/2021-05-20)
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            *released on 2021-05-20*
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              * `fix` [#28](https://github.com/metabahn/corerb/pull/28) Turn off the console logger in all contexts ([bryanp](https://github.com/bryanp))
         
     | 
| 
      
 18 
     | 
    
         
            +
              * `chg` [#27](https://github.com/metabahn/corerb/pull/27) Propagate throws from async contexts ([bryanp](https://github.com/bryanp))
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            ## [v0.5.0](https://github.com/metabahn/corerb/releases/tag/2021-03-26)
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            *released on 2021-03-26*
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              * `chg` [#25](https://github.com/metabahn/corerb/pull/25) Privatize async behavior ([bryanp](https://github.com/bryanp))
         
     | 
| 
      
 25 
     | 
    
         
            +
              * `add` [#24](https://github.com/metabahn/corerb/pull/24) Add Is::Async#cancel ([bryanp](https://github.com/bryanp))
         
     | 
| 
      
 26 
     | 
    
         
            +
              * `fix` [#23](https://github.com/metabahn/corerb/pull/23) Improve control flow during async enumeration / collection building ([bryanp](https://github.com/bryanp))
         
     | 
| 
      
 27 
     | 
    
         
            +
              * `fix` [#22](https://github.com/metabahn/corerb/pull/22) Expose errors that occur when building a collection ([bryanp](https://github.com/bryanp))
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            ## [v0.4.0](https://github.com/metabahn/corerb/releases/tag/2021-03-17.1)
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            *released on 2021-03-17*
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              * `chg` [#21](https://github.com/metabahn/corerb/pull/21) Cancel async futures without waiting ([bryanp](https://github.com/bryanp))
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       1 
35 
     | 
    
         
             
            ## [v0.3.0](https://github.com/metabahn/corerb/releases/tag/2021-03-17)
         
     | 
| 
       2 
36 
     | 
    
         | 
| 
       3 
37 
     | 
    
         
             
            *released on 2021-03-17*
         
     | 
    
        data/lib/core/async/bootstrap.rb
    CHANGED
    
    
| 
         @@ -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/future.rb
    CHANGED
    
    | 
         @@ -25,11 +25,9 @@ module Core 
     | 
|
| 
       25 
25 
     | 
    
         
             
                  def cancel
         
     | 
| 
       26 
26 
     | 
    
         
             
                    if pending?
         
     | 
| 
       27 
27 
     | 
    
         
             
                      @task.stop
         
     | 
| 
       28 
     | 
    
         
            -
                      wait
         
     | 
| 
       29 
     | 
    
         
            -
                      true
         
     | 
| 
       30 
     | 
    
         
            -
                    else
         
     | 
| 
       31 
     | 
    
         
            -
                      false
         
     | 
| 
       32 
28 
     | 
    
         
             
                    end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    self
         
     | 
| 
       33 
31 
     | 
    
         
             
                  end
         
     | 
| 
       34 
32 
     | 
    
         | 
| 
       35 
33 
     | 
    
         
             
                  # [public] Return the result, blocking until available.
         
     | 
| 
         @@ -42,6 +40,8 @@ module Core 
     | 
|
| 
       42 
40 
     | 
    
         
             
                    wait_all(@task)
         
     | 
| 
       43 
41 
     | 
    
         | 
| 
       44 
42 
     | 
    
         
             
                    resolve_value(@task.result)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  rescue UncaughtThrowError => error
         
     | 
| 
      
 44 
     | 
    
         
            +
                    throw error.tag, error.value
         
     | 
| 
       45 
45 
     | 
    
         
             
                  rescue => error
         
     | 
| 
       46 
46 
     | 
    
         
             
                    @error = error
         
     | 
| 
       47 
47 
     | 
    
         | 
    
        data/lib/core/async/version.rb
    CHANGED
    
    
    
        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  
     | 
| 
      
 9 
     | 
    
         
            +
              # [public] Makes objects async-aware.
         
     | 
| 
       10 
10 
     | 
    
         
             
              #
         
     | 
| 
       11 
11 
     | 
    
         
             
              module Async
         
     | 
| 
       12 
12 
     | 
    
         
             
                # [public] Call behavior asychronously, returning a future.
         
     | 
| 
         @@ -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
         
     | 
| 
         @@ -47,11 +47,13 @@ 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.
         
     | 
| 
       53 
55 
     | 
    
         
             
                #
         
     | 
| 
       54 
     | 
    
         
            -
                def aware
         
     | 
| 
      
 56 
     | 
    
         
            +
                private def aware
         
     | 
| 
       55 
57 
     | 
    
         
             
                  if ::Async::Task.current?
         
     | 
| 
       56 
58 
     | 
    
         
             
                    yield
         
     | 
| 
       57 
59 
     | 
    
         
             
                  else
         
     | 
| 
         @@ -63,7 +65,7 @@ module Is 
     | 
|
| 
       63 
65 
     | 
    
         | 
| 
       64 
66 
     | 
    
         
             
                # [public] Sleeps for `seconds` in a proper async context.
         
     | 
| 
       65 
67 
     | 
    
         
             
                #
         
     | 
| 
       66 
     | 
    
         
            -
                def sleep(seconds)
         
     | 
| 
      
 68 
     | 
    
         
            +
                private def sleep(seconds)
         
     | 
| 
       67 
69 
     | 
    
         
             
                  internal_await do |task|
         
     | 
| 
       68 
70 
     | 
    
         
             
                    task.sleep(seconds)
         
     | 
| 
       69 
71 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -73,29 +75,45 @@ module Is 
     | 
|
| 
       73 
75 
     | 
    
         
             
                #
         
     | 
| 
       74 
76 
     | 
    
         
             
                # Raises `Core::Async::Timeout` if execution exceeds `seconds`.
         
     | 
| 
       75 
77 
     | 
    
         
             
                #
         
     | 
| 
       76 
     | 
    
         
            -
                def timeout(seconds 
     | 
| 
      
 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 
     | 
    
         
            -
                         
     | 
| 
      
 86 
     | 
    
         
            +
                        timed_task.wait
         
     | 
| 
       81 
87 
     | 
    
         
             
                      end
         
     | 
| 
       82 
88 
     | 
    
         
             
                    else
         
     | 
| 
       83 
     | 
    
         
            -
                       
     | 
| 
      
 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.
         
     | 
| 
       89 
99 
     | 
    
         
             
                #
         
     | 
| 
       90 
     | 
    
         
            -
                def defer
         
     | 
| 
      
 100 
     | 
    
         
            +
                private def defer
         
     | 
| 
       91 
101 
     | 
    
         
             
                  if (task = ::Async::Task.current?)
         
     | 
| 
       92 
102 
     | 
    
         
             
                    task.yield
         
     | 
| 
       93 
103 
     | 
    
         
             
                  end
         
     | 
| 
       94 
104 
     | 
    
         
             
                end
         
     | 
| 
       95 
105 
     | 
    
         | 
| 
      
 106 
     | 
    
         
            +
                # [public] Cancels the current async behavior if in progress.
         
     | 
| 
      
 107 
     | 
    
         
            +
                #
         
     | 
| 
      
 108 
     | 
    
         
            +
                private def cancel
         
     | 
| 
      
 109 
     | 
    
         
            +
                  if (task = ::Async::Task.current?)
         
     | 
| 
      
 110 
     | 
    
         
            +
                    task.stop
         
     | 
| 
      
 111 
     | 
    
         
            +
                  end
         
     | 
| 
      
 112 
     | 
    
         
            +
                end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
       96 
114 
     | 
    
         
             
                # [public] Resolves a potential future to a final result.
         
     | 
| 
       97 
115 
     | 
    
         
             
                #
         
     | 
| 
       98 
     | 
    
         
            -
                def resolve(value)
         
     | 
| 
      
 116 
     | 
    
         
            +
                private def resolve(value)
         
     | 
| 
       99 
117 
     | 
    
         
             
                  case value
         
     | 
| 
       100 
118 
     | 
    
         
             
                  when Core::Async::Future
         
     | 
| 
       101 
119 
     | 
    
         
             
                    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.7.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- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-07-07 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: async
         
     | 
| 
         @@ -54,14 +54,14 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       54 
54 
     | 
    
         
             
              requirements:
         
     | 
| 
       55 
55 
     | 
    
         
             
              - - ">="
         
     | 
| 
       56 
56 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       57 
     | 
    
         
            -
                  version: 2. 
     | 
| 
      
 57 
     | 
    
         
            +
                  version: '2.7'
         
     | 
| 
       58 
58 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       59 
59 
     | 
    
         
             
              requirements:
         
     | 
| 
       60 
60 
     | 
    
         
             
              - - ">="
         
     | 
| 
       61 
61 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       62 
62 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       63 
63 
     | 
    
         
             
            requirements: []
         
     | 
| 
       64 
     | 
    
         
            -
            rubygems_version: 3.2. 
     | 
| 
      
 64 
     | 
    
         
            +
            rubygems_version: 3.2.15
         
     | 
| 
       65 
65 
     | 
    
         
             
            signing_key:
         
     | 
| 
       66 
66 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       67 
67 
     | 
    
         
             
            summary: Makes Ruby objects async-aware.
         
     |