async 2.14.2 → 2.15.0

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: 12cf95e2d70376d5634d24377bb7d3d3974f14f20227fc33450fb103b17f5783
4
- data.tar.gz: e0c89541d8d039ec1672b68ef1ae90a86a00c065f6143769734bcbf7cc01d7de
3
+ metadata.gz: a4792a06109491eb42dd7eeedc5da5cd0226912efb83883bb6027a2bc7343776
4
+ data.tar.gz: 9fa9867100f4cbbe1a09bd07e0b9cd2db199bd2df35dd422ecc6684bb989260a
5
5
  SHA512:
6
- metadata.gz: cec85cadb861dd14ed374930963e94785e066b8584537e2ef0cc28d8a804372bcf7895f9836d436bd72e20d3f4e0027820ea005dff60120f3d0b66192571e82a
7
- data.tar.gz: f11f62065e7fb9072f06b26514e98c33b6aac2988a485ebaf814792a68abe18711f9842187fcfa66282c8ce0290a1064c575a6d1f8cc5a18269f85f82886fc04
6
+ metadata.gz: 9668ffea1217001a5288ada7f6283622e9280773738d96bbe89195cec6ca8f3887aa14de12d8154474d880604648e2757b5d32d0b1af95f29ad10170d636b53b
7
+ data.tar.gz: 54a021b844db4e50827812a77b365624919dd7ee34bf9e49416a0283d0da7e39d5b2dbcb6879158b45e1bf6032fd871406c412d07b02f14c0046caee98c4a30f
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2017-2022, by Samuel Williams.
4
+ # Copyright, 2017-2024, by Samuel Williams.
5
5
  # Copyright, 2017, by Kent Gruber.
6
6
 
7
7
  require 'fiber'
data/lib/async/idler.rb CHANGED
@@ -41,7 +41,8 @@ module Async
41
41
  backoff = nil
42
42
 
43
43
  while true
44
- load = scheduler.load
44
+ load = scheduler.load
45
+
45
46
  break if load < @maximum_load
46
47
 
47
48
  if backoff
data/lib/async/list.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022, by Samuel Williams.
4
+ # Copyright, 2022-2024, by Samuel Williams.
5
5
 
6
6
  module Async
7
7
  # A general doublely linked list. This is used internally by {Async::Barrier} and {Async::Condition} to manage child tasks.
data/lib/async/node.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2017-2023, by Samuel Williams.
4
+ # Copyright, 2017-2024, by Samuel Williams.
5
5
  # Copyright, 2017, by Kent Gruber.
6
6
  # Copyright, 2022, by Shannon Skipper.
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2018-2022, by Samuel Williams.
4
+ # Copyright, 2018-2024, by Samuel Williams.
5
5
 
6
6
  require_relative 'condition'
7
7
 
data/lib/async/queue.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2018-2022, by Samuel Williams.
4
+ # Copyright, 2018-2024, by Samuel Williams.
5
5
  # Copyright, 2019, by Ryan Musgrave.
6
6
  # Copyright, 2020-2022, by Bruno Sutic.
7
7
 
data/lib/async/reactor.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2017-2022, by Samuel Williams.
4
+ # Copyright, 2017-2024, by Samuel Williams.
5
5
  # Copyright, 2017, by Kent Gruber.
6
6
  # Copyright, 2018, by Sokolov Yura.
7
7
 
@@ -71,7 +71,7 @@ module Async
71
71
  return @busy_time / total_time
72
72
  end
73
73
  end
74
-
74
+
75
75
  # Invoked when the fiber scheduler is being closed.
76
76
  #
77
77
  # Executes the run loop until all tasks are finished, then closes the scheduler.
@@ -84,34 +84,30 @@ module Async
84
84
  self.close
85
85
  end
86
86
 
87
- # Terminate the scheduler. We deliberately ignore interrupts here, as this code can be called from an interrupt, and we don't want to be interrupted while cleaning up.
88
- def terminate
89
- Thread.handle_interrupt(::Interrupt => :never) do
90
- super
87
+ private def shutdown!
88
+ # It's critical to stop all tasks. Otherwise they might be holding on to resources which are never closed/released correctly.
89
+ self.stop
90
+
91
+ self.run_loop do
92
+ unless @children.nil?
93
+ run_once!
94
+ end
91
95
  end
92
96
  end
93
97
 
94
98
  # Terminate all child tasks and close the scheduler.
95
99
  # @public Since `stable-v1`.
96
100
  def close
97
- # It's critical to stop all tasks. Otherwise they might be holding on to resources which are never closed/released correctly.
98
- until self.terminate
99
- self.run_once!
100
- end
101
+ self.shutdown!
101
102
 
102
103
  Kernel.raise "Closing scheduler with blocked operations!" if @blocked > 0
103
-
104
- # We depend on GVL for consistency:
105
- # @guard.synchronize do
106
-
104
+ ensure
107
105
  # We want `@selector = nil` to be a visible side effect from this point forward, specifically in `#interrupt` and `#unblock`. If the selector is closed, then we don't want to push any fibers to it.
108
106
  selector = @selector
109
107
  @selector = nil
110
108
 
111
109
  selector&.close
112
110
 
113
- # end
114
-
115
111
  consume
116
112
  end
117
113
 
@@ -297,7 +293,7 @@ module Async
297
293
  # @parameter timeout [Float | Nil] The maximum timeout, or if nil, indefinite.
298
294
  # @returns [Boolean] Whether there is more work to do.
299
295
  def run_once(timeout = nil)
300
- Kernel::raise "Running scheduler on non-blocking fiber!" unless Fiber.blocking?
296
+ Kernel.raise "Running scheduler on non-blocking fiber!" unless Fiber.blocking?
301
297
 
302
298
  # If we are finished, we stop the task tree and exit:
303
299
  if self.finished?
@@ -313,7 +309,7 @@ module Async
313
309
  #
314
310
  # @parameter timeout [Float | Nil] The maximum timeout, or if nil, indefinite.
315
311
  # @returns [Boolean] Whether there is more work to do.
316
- private def run_once!(timeout = 0)
312
+ private def run_once!(timeout = nil)
317
313
  start_time = Async::Clock.now
318
314
 
319
315
  interval = @timers.wait_interval
@@ -365,38 +361,49 @@ module Async
365
361
  return false
366
362
  end
367
363
 
368
- # Run the reactor until all tasks are finished. Proxies arguments to {#async} immediately before entering the loop, if a block is provided.
369
- def run(...)
370
- Kernel::raise ClosedError if @selector.nil?
371
-
372
- initial_task = self.async(...) if block_given?
364
+ # Stop all children, including transient children, ignoring any signals.
365
+ def stop
366
+ Thread.handle_interrupt(::SignalException => :never) do
367
+ @children&.each do |child|
368
+ child.stop
369
+ end
370
+ end
371
+ end
372
+
373
+ private def run_loop(&block)
373
374
  interrupt = nil
374
375
 
375
376
  begin
376
377
  # In theory, we could use Exception here to be a little bit safer, but we've only shown the case for SignalException to be a problem, so let's not over-engineer this.
377
378
  Thread.handle_interrupt(::SignalException => :never) do
378
- while true
379
- # If we are interrupted, we need to exit:
380
- break if self.interrupted?
381
-
379
+ until self.interrupted?
382
380
  # If we are finished, we need to exit:
383
- break unless self.run_once
381
+ break unless yield
384
382
  end
385
383
  end
386
384
  rescue Interrupt => interrupt
387
- Thread.handle_interrupt(::SignalException => :never) do
388
- self.stop
389
- end
385
+ self.stop
390
386
 
391
387
  retry
392
388
  end
393
389
 
394
390
  # If the event loop was interrupted, and we finished exiting normally (due to the interrupt), we need to re-raise the interrupt so that the caller can handle it too.
395
- Kernel.raise interrupt if interrupt
391
+ Kernel.raise(interrupt) if interrupt
392
+ end
393
+
394
+ # Run the reactor until all tasks are finished. Proxies arguments to {#async} immediately before entering the loop, if a block is provided.
395
+ def run(...)
396
+ Kernel.raise ClosedError if @selector.nil?
397
+
398
+ initial_task = self.async(...) if block_given?
399
+
400
+ self.run_loop do
401
+ unless self.finished?
402
+ run_once!
403
+ end
404
+ end
396
405
 
397
406
  return initial_task
398
- ensure
399
- Console.debug(self) {"Exiting run-loop because #{$! ? $! : 'finished'}."}
400
407
  end
401
408
 
402
409
  # Start an asynchronous task within the specified reactor. The task will be
@@ -409,7 +416,7 @@ module Async
409
416
  # @returns [Task] The task that was scheduled into the reactor.
410
417
  # @deprecated With no replacement.
411
418
  def async(*arguments, **options, &block)
412
- Kernel::raise ClosedError if @selector.nil?
419
+ Kernel.raise ClosedError if @selector.nil?
413
420
 
414
421
  task = Task.new(Task.current? || self, **options, &block)
415
422
 
data/lib/async/task.rb CHANGED
@@ -192,8 +192,8 @@ module Async
192
192
  # I'm not completely happy with this overhead, but the alternative is to not log anything which makes debugging extremely difficult. Maybe we can introduce a debug wrapper which adds extra logging.
193
193
  if @finished.nil?
194
194
  Console::Event::Failure.for(error).emit(self, "Task may have ended with unhandled exception.", severity: :warn)
195
- # else
196
- # Console::Event::Failure.for(error).emit(self, severity: :debug)
195
+ else
196
+ # Console::Event::Failure.for(error).emit(self, severity: :debug)
197
197
  end
198
198
 
199
199
  raise
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
6
  require_relative 'condition'
7
7
 
data/lib/async/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2017-2024, by Samuel Williams.
5
5
 
6
6
  module Async
7
- VERSION = "2.14.2"
7
+ VERSION = "2.15.0"
8
8
  end
data/lib/async/waiter.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022, by Samuel Williams.
4
+ # Copyright, 2022-2024, by Samuel Williams.
5
+ # Copyright, 2024, by Patrik Wenger.
5
6
 
6
7
  module Async
7
8
  # A composable synchronization primitive, which allows one task to wait for a number of other tasks to complete. It can be used in conjunction with {Semaphore} and/or {Barrier}.
data/lib/async/wrapper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2017-2022, by Samuel Williams.
4
+ # Copyright, 2017-2024, by Samuel Williams.
5
5
  # Copyright, 2017, by Kent Gruber.
6
6
 
7
7
  module Async
data/lib/async.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2017-2022, by Samuel Williams.
4
+ # Copyright, 2017-2024, by Samuel Williams.
5
5
  # Copyright, 2020, by Salim Semaoune.
6
6
 
7
7
  require_relative "async/version"
data/license.md CHANGED
@@ -11,7 +11,7 @@ Copyright, 2020-2023, by Olle Jonsson.
11
11
  Copyright, 2020, by Salim Semaoune.
12
12
  Copyright, 2020, by Brian Morearty.
13
13
  Copyright, 2020, by Stefan Wrobel.
14
- Copyright, 2020, by Patrik Wenger.
14
+ Copyright, 2020-2024, by Patrik Wenger.
15
15
  Copyright, 2020, by Ken Muryoi.
16
16
  Copyright, 2020, by Jun Jiang.
17
17
  Copyright, 2020-2022, by Bruno Sutic.
@@ -26,6 +26,7 @@ Copyright, 2023, by Math Ieu.
26
26
  Copyright, 2023, by Emil Tin.
27
27
  Copyright, 2023, by Gert Goet.
28
28
  Copyright, 2024, by Dimitar Peychinov.
29
+ Copyright, 2024, by Jamie McCarthy.
29
30
 
30
31
  Permission is hereby granted, free of charge, to any person obtaining a copy
31
32
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -43,11 +43,11 @@ We welcome contributions to this project.
43
43
 
44
44
  ### Developer Certificate of Origin
45
45
 
46
- This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
46
+ In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
47
47
 
48
- ### Contributor Covenant
48
+ ### Community Guidelines
49
49
 
50
- This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
50
+ This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
51
51
 
52
52
  ## See Also
53
53
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.2
4
+ version: 2.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -9,7 +9,9 @@ authors:
9
9
  - Jeremy Jung
10
10
  - Olle Jonsson
11
11
  - Devin Christensen
12
+ - Patrik Wenger
12
13
  - Emil Tin
14
+ - Jamie McCarthy
13
15
  - Kent Gruber
14
16
  - Brian Morearty
15
17
  - Colin Kelley
@@ -23,7 +25,6 @@ authors:
23
25
  - Masafumi Okura
24
26
  - Masayuki Yamamoto
25
27
  - Math Ieu
26
- - Patrik Wenger
27
28
  - Ryan Musgrave
28
29
  - Salim Semaoune
29
30
  - Shannon Skipper
@@ -62,7 +63,7 @@ cert_chain:
62
63
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
63
64
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
64
65
  -----END CERTIFICATE-----
65
- date: 2024-07-17 00:00:00.000000000 Z
66
+ date: 2024-08-04 00:00:00.000000000 Z
66
67
  dependencies:
67
68
  - !ruby/object:Gem::Dependency
68
69
  name: console
@@ -70,20 +71,14 @@ dependencies:
70
71
  requirements:
71
72
  - - "~>"
72
73
  - !ruby/object:Gem::Version
73
- version: '1.25'
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: 1.25.2
74
+ version: '1.26'
77
75
  type: :runtime
78
76
  prerelease: false
79
77
  version_requirements: !ruby/object:Gem::Requirement
80
78
  requirements:
81
79
  - - "~>"
82
80
  - !ruby/object:Gem::Version
83
- version: '1.25'
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- version: 1.25.2
81
+ version: '1.26'
87
82
  - !ruby/object:Gem::Dependency
88
83
  name: fiber-annotation
89
84
  requirement: !ruby/object:Gem::Requirement
@@ -172,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
167
  - !ruby/object:Gem::Version
173
168
  version: '0'
174
169
  requirements: []
175
- rubygems_version: 3.5.11
170
+ rubygems_version: 3.5.13
176
171
  signing_key:
177
172
  specification_version: 4
178
173
  summary: A concurrency framework for Ruby.
metadata.gz.sig CHANGED
Binary file