async 2.30.0 → 2.31.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1423e2d1cc2a1e1aec71d5e70640a0b8c8069d6a2b2af9da63f7bed3d0c9d548
4
- data.tar.gz: 2529e362cd8141d9fa0d8a6ea29fd0d74298630cdd8d4034633c20365a2c5491
3
+ metadata.gz: 2021787bfa001830a1a65e77ca0162349f4b7c21206077a8583f7cb81268a6b4
4
+ data.tar.gz: af5adae74c2b6e31df15e8885f7f5cad8f18090390d386c8d6373cebca5d1be7
5
5
  SHA512:
6
- metadata.gz: 3455b22a4ea6a6e438e1da05ab9c4f5e7cf4d7f8f465138814c71743b2a6d7c1b1525cc3bb13b065b0aa67d0a57d5409d23cc101c61bd026c6ace345919f0005
7
- data.tar.gz: fb21c61222c5067d272f8e5b845fcdef9ce2f99ab831cebf6575e94068b5e22f365569a2b2af1c5ec704b7e1bf53de93ef4c6143c014e5d77f9995908761b975
6
+ metadata.gz: 27db90ffb96b0b179a311023e73f02837e668a81c7979406b1becf1278f2af8af0aebf24947748feac6b5ba9da0774073d0ae5925e747b7a3c0eb78803ef83c2
7
+ data.tar.gz: 14328112f76c82aa10aff761e23897dec82ae7512a6c5fd72a4f3708c9a828f2d53538a22e49abecfd9bdf30e243c63bb7f4c2feccd088daf208143a77d756c2
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
6
+ require_relative "clock"
7
+
8
+ # @namespace
9
+ module Async
10
+ # Represents a deadline timeout with decrementing remaining time.
11
+ # Includes an efficient representation for zero (non-blocking) timeouts.
12
+ # @public Since *Async v2.31*.
13
+ class Deadline
14
+ # Singleton module for immediate timeouts (zero or negative).
15
+ # Avoids object allocation for fast path (non-blocking) timeouts.
16
+ module Zero
17
+ # Check if the deadline has expired.
18
+ # @returns [Boolean] Always returns true since zero timeouts are immediately expired.
19
+ def self.expired?
20
+ true
21
+ end
22
+
23
+ # Get the remaining time.
24
+ # @returns [Integer] Always returns 0 since zero timeouts have no remaining time.
25
+ def self.remaining
26
+ 0
27
+ end
28
+ end
29
+
30
+ # Create a deadline for the given timeout.
31
+ # @parameter timeout [Numeric | Nil] The timeout duration, or nil for no timeout.
32
+ # @returns [Deadline | Nil] A deadline instance, Zero singleton, or nil.
33
+ def self.start(timeout)
34
+ if timeout.nil?
35
+ nil
36
+ elsif timeout <= 0
37
+ Zero
38
+ else
39
+ self.new(timeout)
40
+ end
41
+ end
42
+
43
+ # Create a new deadline with the specified remaining time.
44
+ # @parameter remaining [Numeric] The initial remaining time.
45
+ def initialize(remaining)
46
+ @remaining = remaining
47
+ @start = Clock.now
48
+ end
49
+
50
+ # Get the remaining time, updating internal state.
51
+ # Each call to this method advances the internal clock and reduces
52
+ # the remaining time by the elapsed duration since the last call.
53
+ # @returns [Numeric] The remaining time (may be negative if expired).
54
+ def remaining
55
+ now = Clock.now
56
+ delta = now - @start
57
+ @start = now
58
+
59
+ @remaining -= delta
60
+
61
+ return @remaining
62
+ end
63
+
64
+ # Check if the deadline has expired.
65
+ # @returns [Boolean] True if no time remains.
66
+ def expired?
67
+ self.remaining <= 0
68
+ end
69
+ end
70
+ end
data/lib/async/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2017-2025, by Samuel Williams.
5
5
 
6
6
  module Async
7
- VERSION = "2.30.0"
7
+ VERSION = "2.31.0"
8
8
  end
data/readme.md CHANGED
@@ -35,6 +35,10 @@ 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.31.0
39
+
40
+ - Introduce `Async::Deadline` for precise timeout management in compound operations.
41
+
38
42
  ### v2.30.0
39
43
 
40
44
  - Add timeout support to `Async::Queue#dequeue` and `Async::Queue#pop` methods.
@@ -81,17 +85,6 @@ This release introduces thread-safety as a core concept of Async. Many core clas
81
85
  - `Async::Task#stop` supports an optional `cause:` argument (that defaults to `$!`), which allows you to specify the cause (exception) for stopping the task.
82
86
  - Add thread-safety agent context.
83
87
 
84
- ### v2.26.0
85
-
86
- - `Async::Notification#signal` now returns `true` if a task was signaled, `false` otherwise, providing better feedback for notification operations.
87
- - `require "async/limited_queue"` is required to use `Async::LimitedQueue` without a deprecation warning. `Async::LimitedQueue` is not deprecated, but it's usage via `async/queue` is deprecated.
88
- - `Async::Task#sleep` is deprecated with no replacement.
89
- - `Async::Task.yield` is deprecated with no replacement.
90
- - `Async::Scheduler#async` is deprecated, use `Async{}`, `Sync{}` or `Async::Task#async` instead.
91
- - Agent context is now available, via the [`agent-context` gem](https://github.com/ioquatix/agent-context).
92
- - [`Async::Barrier` Improvements](https://socketry.github.io/async/releases/index#async::barrier-improvements)
93
- - [Introduce `Async::Queue#close`](https://socketry.github.io/async/releases/index#introduce-async::queue#close)
94
-
95
88
  ## See Also
96
89
 
97
90
  - [async-http](https://github.com/socketry/async-http) — Asynchronous HTTP client/server.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v2.31.0
4
+
5
+ - Introduce `Async::Deadline` for precise timeout management in compound operations.
6
+
3
7
  ## v2.30.0
4
8
 
5
9
  - Add timeout support to `Async::Queue#dequeue` and `Async::Queue#pop` methods.
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.30.0
4
+ version: 2.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -38,6 +38,7 @@ authors:
38
38
  - Sokolov Yura
39
39
  - Stefan Wrobel
40
40
  - Trevor Turk
41
+ autorequire:
41
42
  bindir: bin
42
43
  cert_chain:
43
44
  - |
@@ -69,7 +70,7 @@ cert_chain:
69
70
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
70
71
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
71
72
  -----END CERTIFICATE-----
72
- date: 1980-01-02 00:00:00.000000000 Z
73
+ date: 2025-09-08 00:00:00.000000000 Z
73
74
  dependencies:
74
75
  - !ruby/object:Gem::Dependency
75
76
  name: console
@@ -141,6 +142,8 @@ dependencies:
141
142
  - - "~>"
142
143
  - !ruby/object:Gem::Version
143
144
  version: '0.18'
145
+ description:
146
+ email:
144
147
  executables: []
145
148
  extensions: []
146
149
  extra_rdoc_files: []
@@ -159,6 +162,7 @@ files:
159
162
  - lib/async/condition.md
160
163
  - lib/async/condition.rb
161
164
  - lib/async/console.rb
165
+ - lib/async/deadline.rb
162
166
  - lib/async/idler.rb
163
167
  - lib/async/limited_queue.rb
164
168
  - lib/async/list.rb
@@ -195,6 +199,7 @@ metadata:
195
199
  documentation_uri: https://socketry.github.io/async/
196
200
  funding_uri: https://github.com/sponsors/ioquatix/
197
201
  source_code_uri: https://github.com/socketry/async.git
202
+ post_install_message:
198
203
  rdoc_options: []
199
204
  require_paths:
200
205
  - lib
@@ -209,7 +214,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
214
  - !ruby/object:Gem::Version
210
215
  version: '0'
211
216
  requirements: []
212
- rubygems_version: 3.6.9
217
+ rubygems_version: 3.5.22
218
+ signing_key:
213
219
  specification_version: 4
214
220
  summary: A concurrency framework for Ruby.
215
221
  test_files: []
metadata.gz.sig CHANGED
Binary file