async 2.16.1 → 2.18.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: cd3699fb686c1acc86c39923b81f946f30be577b19eedde83ccb18c156490bfa
4
- data.tar.gz: 27f7af6e0106d94fc8d0a6da188d6c923bc9afce09a32fddad1258367f9d683c
3
+ metadata.gz: 6a94e07aa32d09643fca9fcdb1abed3ea1cc266561331b42f840b39cdb391673
4
+ data.tar.gz: ed364eb2cf2676401edc7a2d35eaab0f9f38e89aed1c66a1b03a0ae5e97a4441
5
5
  SHA512:
6
- metadata.gz: 3e3d03ffcf1b3f7f3d3a4d8f3285092e4a6a6367f91259fbc17aba628d2aa6c8dbbbdcae0093a129a4a7f942f9bcf805d29cfe4e0cd715627ec62098a0e91303
7
- data.tar.gz: 65c681adf6715d125e270b323a39db62cf91efd22628884f48131b68f639ffdd5acc69402181b33f63104a2fb648135f327b2abce8a39d366024be0ca7c30665
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-2022, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'list'
7
- require_relative 'task'
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}.
@@ -4,8 +4,8 @@
4
4
  # Copyright, 2017-2024, by Samuel Williams.
5
5
  # Copyright, 2017, by Kent Gruber.
6
6
 
7
- require 'fiber'
8
- require_relative 'list'
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
@@ -5,9 +5,9 @@
5
5
  # Copyright, 2017, by Kent Gruber.
6
6
  # Copyright, 2022, by Shannon Skipper.
7
7
 
8
- require 'fiber/annotation'
8
+ require "fiber/annotation"
9
9
 
10
- require_relative 'list'
10
+ require_relative "list"
11
11
 
12
12
  module Async
13
13
  # A list of children tasks.
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2018-2024, by Samuel Williams.
5
5
 
6
- require_relative 'condition'
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 'notification'
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 <<(item)
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
@@ -5,7 +5,7 @@
5
5
  # Copyright, 2017, by Kent Gruber.
6
6
  # Copyright, 2018, by Sokolov Yura.
7
7
 
8
- require_relative 'scheduler'
8
+ require_relative "scheduler"
9
9
 
10
10
  module Async
11
11
  # A wrapper around the the scheduler which binds it to the current thread automatically.
@@ -5,13 +5,13 @@
5
5
  # Copyright, 2020, by Jun Jiang.
6
6
  # Copyright, 2021, by Julien Portalier.
7
7
 
8
- require_relative 'clock'
9
- require_relative 'task'
8
+ require_relative "clock"
9
+ require_relative "task"
10
10
 
11
- require 'io/event'
11
+ require "io/event"
12
12
 
13
- require 'console'
14
- require 'resolv'
13
+ require "console"
14
+ require "resolv"
15
15
 
16
16
  module Async
17
17
  # Handles scheduling of fibers. Implements the fiber scheduler interface.
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2018-2023, by Samuel Williams.
4
+ # Copyright, 2018-2024, by Samuel Williams.
5
5
 
6
- require_relative 'list'
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 'fiber'
11
- require 'console/event/failure'
10
+ require "fiber"
11
+ require "console/event/failure"
12
12
 
13
- require_relative 'node'
14
- require_relative 'condition'
13
+ require_relative "node"
14
+ require_relative "condition"
15
15
 
16
16
  Fiber.attr_accessor :async_task
17
17
 
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
- require_relative 'condition'
6
+ require_relative "condition"
7
7
 
8
8
  module Async
9
9
  # A synchronization primitive that allows one task to wait for another task to resolve a value.
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.16.1"
7
+ VERSION = "2.18.0"
8
8
  end
data/lib/kernel/async.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2022, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
6
  require_relative "../async/reactor"
7
7
 
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-2022, by Samuel Williams.
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
- yield task
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.16.1
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-08-26 00:00:00.000000000 Z
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.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.5.11
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