async 2.40.0 → 2.42.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
- checksums.yaml.gz.sig +0 -0
- data/lib/async/scheduler.rb +22 -3
- data/lib/async/version.rb +1 -1
- data/lib/kernel/async.rb +9 -7
- data/lib/kernel/sync.rb +10 -10
- data/readme.md +8 -8
- data/releases.md +8 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f4b0d66ab9efdfe8910e6eced080524be096c8f6b82b2d2fb5477f00bdb0a6da
|
|
4
|
+
data.tar.gz: a35b33bdb575b1c097ccc2fffc3d49eac0ae36054f8bb750d342c21c866961f2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 926c49c93ba5541ee1d3ca5ee3b70024da00f77c71aaf388d604e167f09f664f6e49dc17647ec47ba395f1e9970d36d3e251cc544304caaa2ce37f25617b61f2
|
|
7
|
+
data.tar.gz: 2a07815c98380ec7fce0d4a262b5b06756d9379eb72d35edf8a46b06cc7fa34fa01ae81ff2aaba99731d75ba0bbd7deafc41744b27fce4d5e67d4d03e5c90c2e
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/async/scheduler.rb
CHANGED
|
@@ -525,12 +525,25 @@ module Async
|
|
|
525
525
|
cancel
|
|
526
526
|
end
|
|
527
527
|
|
|
528
|
-
|
|
528
|
+
# Run the event loop, until the scheduler is interrupted or finished.
|
|
529
|
+
#
|
|
530
|
+
# @parameter initial [Proc | Nil] The initial block to execute before the first loop iteration.
|
|
531
|
+
# @yields {...} The block to execute on each loop iteration.
|
|
532
|
+
# @raises {Interrupt} If the scheduler is interrupted.
|
|
533
|
+
private def run_loop(initial = nil, &block)
|
|
529
534
|
interrupt = nil
|
|
530
535
|
|
|
531
536
|
begin
|
|
532
537
|
# 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.
|
|
533
538
|
Thread.handle_interrupt(::SignalException => :never) do
|
|
539
|
+
if initial
|
|
540
|
+
begin
|
|
541
|
+
initial.call
|
|
542
|
+
ensure
|
|
543
|
+
initial = nil
|
|
544
|
+
end
|
|
545
|
+
end
|
|
546
|
+
|
|
534
547
|
until self.interrupted?
|
|
535
548
|
# If we are finished, we need to exit:
|
|
536
549
|
break unless yield
|
|
@@ -570,9 +583,15 @@ module Async
|
|
|
570
583
|
begin
|
|
571
584
|
@profiler&.start
|
|
572
585
|
|
|
573
|
-
initial_task =
|
|
586
|
+
initial_task = nil
|
|
574
587
|
|
|
575
|
-
|
|
588
|
+
if block_given?
|
|
589
|
+
initial = proc do
|
|
590
|
+
initial_task = self.async(...)
|
|
591
|
+
end
|
|
592
|
+
end
|
|
593
|
+
|
|
594
|
+
self.run_loop(initial) do
|
|
576
595
|
run_once
|
|
577
596
|
end
|
|
578
597
|
|
data/lib/async/version.rb
CHANGED
data/lib/kernel/async.rb
CHANGED
|
@@ -27,13 +27,15 @@ module Kernel
|
|
|
27
27
|
elsif scheduler = Fiber.scheduler
|
|
28
28
|
::Async::Task.run(scheduler, ...)
|
|
29
29
|
else
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
Fiber.blocking do
|
|
31
|
+
# This calls Fiber.set_scheduler(self):
|
|
32
|
+
reactor = ::Async::Reactor.new
|
|
33
|
+
|
|
34
|
+
begin
|
|
35
|
+
return reactor.run(...)
|
|
36
|
+
ensure
|
|
37
|
+
Fiber.set_scheduler(nil)
|
|
38
|
+
end
|
|
37
39
|
end
|
|
38
40
|
end
|
|
39
41
|
end
|
data/lib/kernel/sync.rb
CHANGED
|
@@ -27,16 +27,16 @@ module Kernel
|
|
|
27
27
|
elsif scheduler = Fiber.scheduler
|
|
28
28
|
::Async::Task.run(scheduler, &block).wait
|
|
29
29
|
else
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
Fiber.blocking do
|
|
31
|
+
# This calls Fiber.set_scheduler(self):
|
|
32
|
+
reactor = Async::Reactor.new
|
|
33
|
+
|
|
34
|
+
begin
|
|
35
|
+
# Use finished: false to suppress warnings since we're handling exceptions explicitly
|
|
36
|
+
return reactor.run(annotation: annotation, finished: false, &block).wait
|
|
37
|
+
ensure
|
|
38
|
+
Fiber.set_scheduler(nil)
|
|
39
|
+
end
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
end
|
data/readme.md
CHANGED
|
@@ -35,6 +35,14 @@ Please see the [project documentation](https://socketry.github.io/async/) for mo
|
|
|
35
35
|
|
|
36
36
|
Please see the [project releases](https://socketry.github.io/async/releases/index) for all releases.
|
|
37
37
|
|
|
38
|
+
### v2.42.0
|
|
39
|
+
|
|
40
|
+
- `Sync` and `Async` can now be invoked from a non-blocking fiber that has no scheduler (e.g. inside an `Enumerator` or a bare `Fiber.new`). Previously this raised `RuntimeError: Running scheduler on non-blocking fiber!`. The reactor is now run within `Fiber.blocking`, so the scheduler always runs on a blocking fiber.
|
|
41
|
+
|
|
42
|
+
### v2.41.0
|
|
43
|
+
|
|
44
|
+
- **Fixed**: Protect initial task from Interrupt exceptions.
|
|
45
|
+
|
|
38
46
|
### v2.40.0
|
|
39
47
|
|
|
40
48
|
- Introduce `Async::Condition#waiting_count`. This allows you to see how many tasks are currently waiting on the condition, which can be useful for debugging and monitoring purposes.
|
|
@@ -71,14 +79,6 @@ Please see the [project releases](https://socketry.github.io/async/releases/inde
|
|
|
71
79
|
- Improved handling of `Process.fork` on Ruby 4+.
|
|
72
80
|
- Improve `@promise` state handling in `Task#initialize`, preventing incomplete instances being visible to the scheduler.
|
|
73
81
|
|
|
74
|
-
### v2.35.1
|
|
75
|
-
|
|
76
|
-
- Fix incorrect handling of spurious wakeups in `Async::Promise#wait`, which could lead to premature (incorrect) resolution of the promise.
|
|
77
|
-
|
|
78
|
-
### v2.35.0
|
|
79
|
-
|
|
80
|
-
- `Process.fork` is now properly handled by the Async fiber scheduler, ensuring that the scheduler state is correctly reset in the child process after a fork. This prevents issues where the child process inherits the scheduler state from the parent, which could lead to unexpected behavior.
|
|
81
|
-
|
|
82
82
|
## See Also
|
|
83
83
|
|
|
84
84
|
- [async-http](https://github.com/socketry/async-http) — Asynchronous HTTP client/server.
|
data/releases.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v2.42.0
|
|
4
|
+
|
|
5
|
+
- `Sync` and `Async` can now be invoked from a non-blocking fiber that has no scheduler (e.g. inside an `Enumerator` or a bare `Fiber.new`). Previously this raised `RuntimeError: Running scheduler on non-blocking fiber!`. The reactor is now run within `Fiber.blocking`, so the scheduler always runs on a blocking fiber.
|
|
6
|
+
|
|
7
|
+
## v2.41.0
|
|
8
|
+
|
|
9
|
+
- **Fixed**: Protect initial task from Interrupt exceptions.
|
|
10
|
+
|
|
3
11
|
## v2.40.0
|
|
4
12
|
|
|
5
13
|
- Introduce `Async::Condition#waiting_count`. This allows you to see how many tasks are currently waiting on the condition, which can be useful for debugging and monitoring purposes.
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|