async 2.0.2 → 2.0.3

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: fc0f12596e4e5aa4503ad424d70afbf365a143b18401102934db193c81241982
4
- data.tar.gz: 0f7b7072662acb0d45cfb548aa07e96486ebbba8fdd3aa32ce2db3304235a726
3
+ metadata.gz: 4e8368066a9018b0f3c21ee8c4387cebc233250a4d01697a06051aceee67924b
4
+ data.tar.gz: 80dbe862ee18e562c20acd59c428e2d9ef9b17097229621c3d22cdafb2705f5e
5
5
  SHA512:
6
- metadata.gz: 9accc918375f64401d7f6f1f5086e84a50a367b18caf100dce07ca1ec39f1ddb5411b8072f1d498ace92ba31beb4f6ee0ab4b9b26de8f3afc94a6d0c5c05d57b
7
- data.tar.gz: 997b2d6622b543387a43a4b8962e66b80da20ee71e7a9fb61565b5969421f36cb12aa88a94a31c99dd3311216a621886467553cb0d2fbec56f951e8322b84d84
6
+ metadata.gz: b4a0786f488161edbf99e3933f983938561d79f9d9f94902dcb4c79120ffe12c2743cc69aad1d258bbe1aae5bab10a90007ae0065e22576885377b11e423df1b
7
+ data.tar.gz: 224c584693a4a714d7cd9e10062c7975c7fbd8b785f84e46e44151acebb5bc74b136bb9eec5d1d828c5fbfc7cd853e29fb63cd5de3ae7afc8c232e2f9e0af722
checksums.yaml.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ <ռ�oݲ[�B��p�����&���������68����|�=4��o+>�Ž��`�W������P;�J����'�hA/=�x�
2
+ rre�N%�­ x��A�<��a5&�[�_��z���vݸi�u:)l�����NgN�� /� ��m�̖�0����@u�T_V�� �p���Ck볅�
3
+ �U6�]w$�!U?� �DC�Q虶��}b����/��A���IJB���aʠlXIj�h�Lz�S�ѠԀ���1[G�:�6�Ke�Zn�gH�ڶ���� @����gV��!u�۵���
data/lib/async/queue.rb CHANGED
@@ -43,14 +43,16 @@ module Async
43
43
  @items.empty?
44
44
  end
45
45
 
46
- def enqueue(item)
47
- @items.push(item)
46
+ def <<(item)
47
+ @items << item
48
48
 
49
49
  self.signal unless self.empty?
50
50
  end
51
51
 
52
- def <<(item)
53
- enqueue(item)
52
+ def enqueue(*items)
53
+ @items.concat(items)
54
+
55
+ self.signal unless self.empty?
54
56
  end
55
57
 
56
58
  def dequeue
@@ -91,7 +93,7 @@ module Async
91
93
  @items.size >= @limit
92
94
  end
93
95
 
94
- def enqueue item
96
+ def <<(item)
95
97
  while limited?
96
98
  @full.wait
97
99
  end
@@ -99,6 +101,19 @@ module Async
99
101
  super
100
102
  end
101
103
 
104
+ def enqueue *items
105
+ while !items.empty?
106
+ while limited?
107
+ @full.wait
108
+ end
109
+
110
+ available = @limit - @items.size
111
+ @items.concat(items.shift(available))
112
+
113
+ self.signal unless self.empty?
114
+ end
115
+ end
116
+
102
117
  def dequeue
103
118
  item = super
104
119
 
@@ -102,11 +102,7 @@ module Async
102
102
  end
103
103
 
104
104
  def resume(fiber, *arguments)
105
- if Fiber.scheduler
106
- @selector.resume(fiber, *arguments)
107
- else
108
- @selector.push(fiber)
109
- end
105
+ @selector.resume(fiber, *arguments)
110
106
  end
111
107
 
112
108
  # Invoked when a fiber tries to perform a blocking operation which cannot continue. A corresponding call {unblock} must be performed to allow this fiber to continue.
data/lib/async/task.rb CHANGED
@@ -163,7 +163,7 @@ module Async
163
163
  if self.running?
164
164
  if self.current?
165
165
  if later
166
- Fiber.scheduler.push Stop::Later.new(self)
166
+ Fiber.scheduler.push(Stop::Later.new(self))
167
167
  else
168
168
  raise Stop, "Stopping current task!"
169
169
  end
@@ -171,7 +171,7 @@ module Async
171
171
  begin
172
172
  Fiber.scheduler.raise(@fiber, Stop)
173
173
  rescue FiberError
174
- Fiber.scheduler.push Stop::Later.new(self)
174
+ Fiber.scheduler.push(Stop::Later.new(self))
175
175
  end
176
176
  end
177
177
  else
@@ -206,17 +206,13 @@ module Async
206
206
  # Whether we can remove this node from the reactor graph.
207
207
  # @returns [Boolean]
208
208
  def finished?
209
- super && @status != :running
209
+ super && @fiber.nil?
210
210
  end
211
211
 
212
212
  def failed?
213
213
  @status == :failed
214
214
  end
215
215
 
216
- def stopping?
217
- @status == :stopping
218
- end
219
-
220
216
  def stopped?
221
217
  @status == :stopped
222
218
  end
@@ -228,18 +224,19 @@ module Async
228
224
  private
229
225
 
230
226
  # This is a very tricky aspect of tasks to get right. I've modelled it after `Thread` but it's slightly different in that the exception can propagate back up through the reactor. If the user writes code which raises an exception, that exception should always be visible, i.e. cause a failure. If it's not visible, such code fails silently and can be very difficult to debug.
231
- # As an explcit choice, the user can start a task which doesn't propagate exceptions. This only applies to `StandardError` and derived tasks. This allows tasks to internally capture their error state which is raised when invoking `Task#result` similar to how `Thread#join` works. This mode makes {ruby Async::Task} behave more like a promise, and you would need to ensure that someone calls `Task#result` otherwise you might miss important errors.
232
- def fail!(exception = nil, propagate = true)
227
+ def fail!(exception = false, propagate = true)
233
228
  @status = :failed
234
229
  @result = exception
235
230
 
236
- if propagate
237
- raise
238
- elsif @finished.nil?
239
- # If no one has called wait, we log this as an error:
240
- Console.logger.error(self) {$!}
241
- else
242
- Console.logger.debug(self) {$!}
231
+ if exception
232
+ if propagate
233
+ raise exception
234
+ elsif @finished.nil?
235
+ # If no one has called wait, we log this as a warning:
236
+ Console.logger.warn(self, "Task may have ended with unhandled exception.", exception)
237
+ else
238
+ Console.logger.debug(self, exception)
239
+ end
243
240
  end
244
241
  end
245
242
 
data/lib/async/version.rb CHANGED
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Async
24
- VERSION = "2.0.2"
24
+ VERSION = "2.0.3"
25
25
  end
data/lib/async/wrapper.rb CHANGED
@@ -64,7 +64,7 @@ module Async
64
64
  # Wait fo the io to become either readable or writable.
65
65
  # @parameter duration [Float] timeout after the given duration if not `nil`.
66
66
  def wait_any(timeout = @timeout)
67
- @io.wait_any(timeout) or raise TimeoutError
67
+ @io.to_io.wait(::IO::READABLE|::IO::WRITABLE|::IO::PRIORITY, timeout) or raise TimeoutError
68
68
  end
69
69
 
70
70
  # Close the io and monitor.
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
- - Devin Christensen
9
8
  - Bruno Sutic
9
+ - Devin Christensen
10
10
  - Jeremy Jung
11
11
  - Kent Gruber
12
12
  - jeremyjung
@@ -24,8 +24,36 @@ authors:
24
24
  - muryoimpl
25
25
  autorequire:
26
26
  bindir: bin
27
- cert_chain: []
28
- date: 2022-05-04 00:00:00.000000000 Z
27
+ cert_chain:
28
+ - |
29
+ -----BEGIN CERTIFICATE-----
30
+ MIIEhDCCAuygAwIBAgIBATANBgkqhkiG9w0BAQsFADA3MTUwMwYDVQQDDCxzYW11
31
+ ZWwud2lsbGlhbXMvREM9b3Jpb250cmFuc2Zlci9EQz1jby9EQz1uejAeFw0yMTA4
32
+ MTYwNjMzNDRaFw0yMjA4MTYwNjMzNDRaMDcxNTAzBgNVBAMMLHNhbXVlbC53aWxs
33
+ aWFtcy9EQz1vcmlvbnRyYW5zZmVyL0RDPWNvL0RDPW56MIIBojANBgkqhkiG9w0B
34
+ AQEFAAOCAY8AMIIBigKCAYEAyXLSS/cw+fXJ5e7hi+U/TeChPWeYdwJojDsFY1xr
35
+ xvtqbTTL8gbLHz5LW3QD2nfwCv3qTlw0qI3Ie7a9VMJMbSvgVEGEfQirqIgJXWMj
36
+ eNMDgKsMJtC7u/43abRKx7TCURW3iWyR19NRngsJJmaR51yGGGm2Kfsr+JtKKLtL
37
+ L188Wm3f13KAx7QJU8qyuBnj1/gWem076hzdA7xi1DbrZrch9GCRz62xymJlrJHn
38
+ 9iZEZ7AxrS7vokhMlzSr/XMUihx/8aFKtk+tMLClqxZSmBWIErWdicCGTULXCBNb
39
+ E/mljo4zE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-06-15 00:00:00.000000000 Z
29
57
  dependencies:
30
58
  - !ruby/object:Gem::Dependency
31
59
  name: console
metadata.gz.sig ADDED
Binary file