async 2.16.1 → 2.18.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/barrier.rb +3 -3
- data/lib/async/condition.rb +2 -2
- data/lib/async/node.rb +2 -2
- data/lib/async/notification.rb +1 -1
- data/lib/async/queue.rb +9 -3
- data/lib/async/reactor.rb +1 -1
- data/lib/async/scheduler.rb +5 -5
- data/lib/async/semaphore.rb +2 -2
- data/lib/async/task.rb +4 -4
- data/lib/async/variable.rb +1 -1
- data/lib/async/version.rb +1 -1
- data/lib/kernel/async.rb +1 -1
- data/lib/kernel/sync.rb +9 -4
- data/readme.md +8 -0
- data/releases.md +8 -0
- data.tar.gz.sig +0 -0
- metadata +5 -5
- 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: 6a94e07aa32d09643fca9fcdb1abed3ea1cc266561331b42f840b39cdb391673
|
4
|
+
data.tar.gz: ed364eb2cf2676401edc7a2d35eaab0f9f38e89aed1c66a1b03a0ae5e97a4441
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 353f270a396696c8a689e5e48657a0c06efb21a6a5d6ade30c68c54b7bd09c7b123466b6a382237deffa6f15ce186ececcf49b52d814cafff7bd4c446db3910c
|
7
|
+
data.tar.gz: 7390bd9fbef443a145dbbfd17f593cb0dffd91021ecb38cd3441a4a6ac7c04394197b512f177595739608a498f54c5619e14fd23ce0c0100a7b45eaa9b0bb3a6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/async/barrier.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
6
|
+
require_relative "list"
|
7
|
+
require_relative "task"
|
8
8
|
|
9
9
|
module Async
|
10
10
|
# A general purpose synchronisation primitive, which allows one task to wait for a number of other tasks to complete. It can be used in conjunction with {Semaphore}.
|
data/lib/async/condition.rb
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
# Copyright, 2017-2024, by Samuel Williams.
|
5
5
|
# Copyright, 2017, by Kent Gruber.
|
6
6
|
|
7
|
-
require
|
8
|
-
require_relative
|
7
|
+
require "fiber"
|
8
|
+
require_relative "list"
|
9
9
|
|
10
10
|
module Async
|
11
11
|
# A synchronization primitive, which allows fibers to wait until a particular condition is (edge) triggered.
|
data/lib/async/node.rb
CHANGED
data/lib/async/notification.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2018-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative "condition"
|
7
7
|
|
8
8
|
module Async
|
9
9
|
# A synchronization primitive, which allows fibers to wait until a notification is received. Does not block the task which signals the notification. Waiting tasks are resumed on next iteration of the reactor.
|
data/lib/async/queue.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Copyright, 2019, by Ryan Musgrave.
|
6
6
|
# Copyright, 2020-2022, by Bruno Sutic.
|
7
7
|
|
8
|
-
require_relative
|
8
|
+
require_relative "notification"
|
9
9
|
|
10
10
|
module Async
|
11
11
|
# A queue which allows items to be processed in order.
|
@@ -38,12 +38,15 @@ module Async
|
|
38
38
|
end
|
39
39
|
|
40
40
|
# Add an item to the queue.
|
41
|
-
def
|
41
|
+
def push(item)
|
42
42
|
@items << item
|
43
43
|
|
44
44
|
@available.signal unless self.empty?
|
45
45
|
end
|
46
46
|
|
47
|
+
# Compatibility with {::Queue#push}.
|
48
|
+
alias << push
|
49
|
+
|
47
50
|
# Add multiple items to the queue.
|
48
51
|
def enqueue(*items)
|
49
52
|
@items.concat(items)
|
@@ -60,6 +63,9 @@ module Async
|
|
60
63
|
@items.shift
|
61
64
|
end
|
62
65
|
|
66
|
+
# Compatibility with {::Queue#pop}.
|
67
|
+
alias pop dequeue
|
68
|
+
|
63
69
|
# Process each item in the queue.
|
64
70
|
#
|
65
71
|
# @asynchronous Executes the given block concurrently for each item.
|
@@ -82,7 +88,7 @@ module Async
|
|
82
88
|
end
|
83
89
|
|
84
90
|
# Signal the queue with a value, the same as {#enqueue}.
|
85
|
-
def signal(value)
|
91
|
+
def signal(value = nil)
|
86
92
|
self.enqueue(value)
|
87
93
|
end
|
88
94
|
|
data/lib/async/reactor.rb
CHANGED
data/lib/async/scheduler.rb
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
# Copyright, 2020, by Jun Jiang.
|
6
6
|
# Copyright, 2021, by Julien Portalier.
|
7
7
|
|
8
|
-
require_relative
|
9
|
-
require_relative
|
8
|
+
require_relative "clock"
|
9
|
+
require_relative "task"
|
10
10
|
|
11
|
-
require
|
11
|
+
require "io/event"
|
12
12
|
|
13
|
-
require
|
14
|
-
require
|
13
|
+
require "console"
|
14
|
+
require "resolv"
|
15
15
|
|
16
16
|
module Async
|
17
17
|
# Handles scheduling of fibers. Implements the fiber scheduler interface.
|
data/lib/async/semaphore.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2018-
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative "list"
|
7
7
|
|
8
8
|
module Async
|
9
9
|
# A synchronization primitive, which limits access to a given resource.
|
data/lib/async/task.rb
CHANGED
@@ -7,11 +7,11 @@
|
|
7
7
|
# Copyright, 2020, by Patrik Wenger.
|
8
8
|
# Copyright, 2023, by Math Ieu.
|
9
9
|
|
10
|
-
require
|
11
|
-
require
|
10
|
+
require "fiber"
|
11
|
+
require "console/event/failure"
|
12
12
|
|
13
|
-
require_relative
|
14
|
-
require_relative
|
13
|
+
require_relative "node"
|
14
|
+
require_relative "condition"
|
15
15
|
|
16
16
|
Fiber.attr_accessor :async_task
|
17
17
|
|
data/lib/async/variable.rb
CHANGED
data/lib/async/version.rb
CHANGED
data/lib/kernel/async.rb
CHANGED
data/lib/kernel/sync.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
# Copyright, 2020, by Brian Morearty.
|
6
|
+
# Copyright, 2024, by Patrik Wenger.
|
6
7
|
|
7
8
|
require_relative "../async/reactor"
|
8
9
|
|
@@ -15,9 +16,13 @@ module Kernel
|
|
15
16
|
#
|
16
17
|
# @public Since `stable-v1`.
|
17
18
|
# @asynchronous Will block until given block completes executing.
|
18
|
-
def Sync(&block)
|
19
|
+
def Sync(annotation: nil, &block)
|
19
20
|
if task = ::Async::Task.current?
|
20
|
-
|
21
|
+
if annotation
|
22
|
+
task.annotate(annotation) {yield task}
|
23
|
+
else
|
24
|
+
yield task
|
25
|
+
end
|
21
26
|
elsif scheduler = Fiber.scheduler
|
22
27
|
::Async::Task.run(scheduler, &block).wait
|
23
28
|
else
|
@@ -25,7 +30,7 @@ module Kernel
|
|
25
30
|
reactor = Async::Reactor.new
|
26
31
|
|
27
32
|
begin
|
28
|
-
return reactor.run(finished: ::Async::Condition.new, &block).wait
|
33
|
+
return reactor.run(annotation: annotation, finished: ::Async::Condition.new, &block).wait
|
29
34
|
ensure
|
30
35
|
Fiber.set_scheduler(nil)
|
31
36
|
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.18.0
|
39
|
+
|
40
|
+
- Add support for `Sync(annotation:)`, so that you can annotate the block with a description of what it does, even if it doesn't create a new task.
|
41
|
+
|
42
|
+
### v2.17.0
|
43
|
+
|
44
|
+
- Introduce `Async::Queue#push` and `Async::Queue#pop` for compatibility with `::Queue`.
|
45
|
+
|
38
46
|
### v2.16.0
|
39
47
|
|
40
48
|
- [Better Handling of Async and Sync in Nested Fibers](https://socketry.github.io/async/releases/index#better-handling-of-async-and-sync-in-nested-fibers)
|
data/releases.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Releases
|
2
2
|
|
3
|
+
## v2.18.0
|
4
|
+
|
5
|
+
- Add support for `Sync(annotation:)`, so that you can annotate the block with a description of what it does, even if it doesn't create a new task.
|
6
|
+
|
7
|
+
## v2.17.0
|
8
|
+
|
9
|
+
- Introduce `Async::Queue#push` and `Async::Queue#pop` for compatibility with `::Queue`.
|
10
|
+
|
3
11
|
## v2.16.0
|
4
12
|
|
5
13
|
### Better Handling of Async and Sync in Nested Fibers
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
- Bruno Sutic
|
9
9
|
- Jeremy Jung
|
10
10
|
- Olle Jonsson
|
11
|
-
- Devin Christensen
|
12
11
|
- Patrik Wenger
|
12
|
+
- Devin Christensen
|
13
13
|
- Emil Tin
|
14
14
|
- Jamie McCarthy
|
15
15
|
- Kent Gruber
|
@@ -63,7 +63,7 @@ cert_chain:
|
|
63
63
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
64
64
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
65
65
|
-----END CERTIFICATE-----
|
66
|
-
date: 2024-
|
66
|
+
date: 2024-10-29 00:00:00.000000000 Z
|
67
67
|
dependencies:
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
name: console
|
@@ -161,14 +161,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
161
161
|
requirements:
|
162
162
|
- - ">="
|
163
163
|
- !ruby/object:Gem::Version
|
164
|
-
version: 3.1
|
164
|
+
version: '3.1'
|
165
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
166
|
requirements:
|
167
167
|
- - ">="
|
168
168
|
- !ruby/object:Gem::Version
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
|
-
rubygems_version: 3.
|
171
|
+
rubygems_version: 3.3.8
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: A concurrency framework for Ruby.
|
metadata.gz.sig
CHANGED
Binary file
|