async 1.30.1 → 1.30.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8503897fe2c8f3b9593655310b259ee33d2a3774e65d7882524289286cea163
4
- data.tar.gz: 952c6d1fd722b83efb95ffc3e4153c87d5925359aa403235f63496f984699588
3
+ metadata.gz: 505786d92573cb06d44ba76fdf587c1a8d5ac1eab7e373fbb5380f85ada6686e
4
+ data.tar.gz: bc935c07dcbe370ff7379971e670548be2133891e3f4ba703e434e109d691283
5
5
  SHA512:
6
- metadata.gz: 7b6c1a440279e389c4750ac7b7b716d19f05e31b29c67e3b712692b54877dca265eff31994d9a9220a1be7fa44fc79622f244a188e470e46f4a52b343e8b7638
7
- data.tar.gz: 1c33f438780355d349dbe78ea0706cfcdc4165f3f402aae26042414f01a975e20a1f244621ca1486c36d10877b7b4d825a4c0aed6ef6a3a69dc0a41c1cd38ace
6
+ metadata.gz: 479cb9a9fad1eeae60993051cd91d8698b47f7dc6fd0129b4672bedf8bcb572c0515d91f5a0d4872da3c2f7d72941c316d86b9d9784fcb2744b1c746c8ba7f20
7
+ data.tar.gz: c954400df7d37eb5f85dda0365390eb77205a0e2293a3c43291136bf1abcdc522c7b5171e465fa4d1026e9d704a9a7b30c1a765633d0e4c5249b1973b3e7036e
data/lib/async/barrier.rb CHANGED
@@ -60,8 +60,11 @@ module Async
60
60
  begin
61
61
  task.wait
62
62
  ensure
63
- # Remove the task from the waiting list if it's finished:
64
- @tasks.shift if @tasks.first == task
63
+ # We don't know for sure that the exception was due to the task completion.
64
+ unless task.running?
65
+ # Remove the task from the waiting list if it's finished:
66
+ @tasks.shift if @tasks.first == task
67
+ end
65
68
  end
66
69
  end
67
70
  end
@@ -21,7 +21,6 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  require 'fiber'
24
- require 'forwardable'
25
24
  require_relative 'node'
26
25
 
27
26
  module Async
data/lib/async/queue.rb CHANGED
@@ -48,7 +48,9 @@ module Async
48
48
  self.signal unless self.empty?
49
49
  end
50
50
 
51
- alias << enqueue
51
+ def <<(item)
52
+ enqueue(item)
53
+ end
52
54
 
53
55
  def dequeue
54
56
  while @items.empty?
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require_relative 'condition'
24
+
25
+ module Async
26
+ class Variable
27
+ def initialize(condition = Condition.new)
28
+ @condition = condition
29
+ @value = nil
30
+ end
31
+
32
+ def resolve(value = true)
33
+ @value = value
34
+ condition = @condition
35
+ @condition = nil
36
+
37
+ self.freeze
38
+
39
+ condition.signal(value)
40
+ end
41
+
42
+ def resolved?
43
+ @condition.nil?
44
+ end
45
+
46
+ def value
47
+ @condition&.wait
48
+ return @value
49
+ end
50
+
51
+ def wait
52
+ self.value
53
+ end
54
+ end
55
+ end
data/lib/async/version.rb CHANGED
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Async
24
- VERSION = "1.30.1"
24
+ VERSION = "1.30.2"
25
25
  end
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.30.1
4
+ version: 1.30.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-29 00:00:00.000000000 Z
11
+ date: 2022-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: console
@@ -156,6 +156,7 @@ files:
156
156
  - lib/async/scheduler.rb
157
157
  - lib/async/semaphore.rb
158
158
  - lib/async/task.rb
159
+ - lib/async/variable.rb
159
160
  - lib/async/version.rb
160
161
  - lib/async/wrapper.rb
161
162
  - lib/kernel/async.rb
@@ -179,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
180
  - !ruby/object:Gem::Version
180
181
  version: '0'
181
182
  requirements: []
182
- rubygems_version: 3.0.3.1
183
+ rubygems_version: 3.1.6
183
184
  signing_key:
184
185
  specification_version: 4
185
186
  summary: A concurrency framework for Ruby.