e621stream 0.0.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 +7 -0
- data/LICENSE +21 -0
- data/README.md +35 -0
- data/lib/e621stream/client/options.rb +20 -0
- data/lib/e621stream/client.rb +211 -0
- data/lib/e621stream/close_codes.rb +23 -0
- data/lib/e621stream/event.rb +24 -0
- data/lib/e621stream/events.rb +29 -0
- data/lib/e621stream/stream_error.rb +18 -0
- data/lib/e621stream/version.rb +5 -0
- data/lib/e621stream.rb +18 -0
- data/sorbet/config +6 -0
- data/sorbet/rbi/annotations/.gitattributes +1 -0
- data/sorbet/rbi/annotations/minitest.rbi +120 -0
- data/sorbet/rbi/annotations/rainbow.rbi +269 -0
- data/sorbet/rbi/gems/.gitattributes +1 -0
- data/sorbet/rbi/gems/ast@2.4.3.rbi +550 -0
- data/sorbet/rbi/gems/async-http@0.105.0.rbi +1649 -0
- data/sorbet/rbi/gems/async-pool@0.12.0.rbi +219 -0
- data/sorbet/rbi/gems/async-websocket@0.30.2.rbi +271 -0
- data/sorbet/rbi/gems/async@2.46.0.rbi +2193 -0
- data/sorbet/rbi/gems/benchmark@0.5.0.rbi +495 -0
- data/sorbet/rbi/gems/console@1.38.0.rbi +1552 -0
- data/sorbet/rbi/gems/erb@6.0.7.rbi +1581 -0
- data/sorbet/rbi/gems/erubi@1.13.1.rbi +153 -0
- data/sorbet/rbi/gems/fiber-annotation@0.2.0.rbi +62 -0
- data/sorbet/rbi/gems/fiber-local@1.1.0.rbi +36 -0
- data/sorbet/rbi/gems/fiber-storage@1.0.1.rbi +43 -0
- data/sorbet/rbi/gems/io-console@0.9.5.rbi +9 -0
- data/sorbet/rbi/gems/io-endpoint@0.19.0.rbi +1079 -0
- data/sorbet/rbi/gems/io-event@1.22.3.rbi +971 -0
- data/sorbet/rbi/gems/io-stream@0.14.0.rbi +805 -0
- data/sorbet/rbi/gems/json@3.1.0.rbi +1929 -0
- data/sorbet/rbi/gems/language_server-protocol@3.17.0.6.rbi +9 -0
- data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +189 -0
- data/sorbet/rbi/gems/logger@1.7.0.rbi +896 -0
- data/sorbet/rbi/gems/minitest@5.27.0.rbi +1499 -0
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +147 -0
- data/sorbet/rbi/gems/openssl@4.0.2.rbi +4366 -0
- data/sorbet/rbi/gems/parallel@2.3.0.rbi +332 -0
- data/sorbet/rbi/gems/parser@3.3.13.0.rbi +5146 -0
- data/sorbet/rbi/gems/pp@0.6.4.rbi +373 -0
- data/sorbet/rbi/gems/prettyprint@0.2.1.rbi +476 -0
- data/sorbet/rbi/gems/prism@1.9.0.rbi +42213 -0
- data/sorbet/rbi/gems/protocol-hpack@1.5.1.rbi +418 -0
- data/sorbet/rbi/gems/protocol-http1@0.41.1.rbi +894 -0
- data/sorbet/rbi/gems/protocol-http2@0.29.2.rbi +2277 -0
- data/sorbet/rbi/gems/protocol-http@0.72.1.rbi +3801 -0
- data/sorbet/rbi/gems/protocol-rack@0.23.0.rbi +9 -0
- data/sorbet/rbi/gems/protocol-url@0.19.0.rbi +9 -0
- data/sorbet/rbi/gems/protocol-websocket@0.21.3.rbi +1087 -0
- data/sorbet/rbi/gems/racc@1.8.1.rbi +169 -0
- data/sorbet/rbi/gems/rack@3.2.8.rbi +9 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +362 -0
- data/sorbet/rbi/gems/rake@13.4.2.rbi +3127 -0
- data/sorbet/rbi/gems/rbi@0.5.0.rbi +5875 -0
- data/sorbet/rbi/gems/rbs@4.2.0.rbi +7133 -0
- data/sorbet/rbi/gems/rdoc@8.1.0.rbi +9 -0
- data/sorbet/rbi/gems/regexp_parser@2.13.1.rbi +3500 -0
- data/sorbet/rbi/gems/reline@0.7.0.rbi +2449 -0
- data/sorbet/rbi/gems/require-hooks@0.5.1.rbi +152 -0
- data/sorbet/rbi/gems/rexml@3.4.4.rbi +4905 -0
- data/sorbet/rbi/gems/rubocop-ast@1.51.0.rbi +7230 -0
- data/sorbet/rbi/gems/rubocop-rake@0.7.1.rbi +314 -0
- data/sorbet/rbi/gems/rubocop@1.92.2.rbi +69094 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +988 -0
- data/sorbet/rbi/gems/rubydex@0.4.4.rbi +1620 -0
- data/sorbet/rbi/gems/spoom@1.8.13.rbi +7380 -0
- data/sorbet/rbi/gems/tapioca@0.20.0.rbi +3752 -0
- data/sorbet/rbi/gems/thor@1.5.0.rbi +3870 -0
- data/sorbet/rbi/gems/tsort@0.2.0.rbi +389 -0
- data/sorbet/rbi/gems/unicode-display_width@3.3.0.rbi +130 -0
- data/sorbet/rbi/gems/unicode-emoji@4.3.0.rbi +254 -0
- data/sorbet/rbi/gems/zeitwerk@2.8.3.rbi +1178 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +4 -0
- metadata +175 -0
|
@@ -0,0 +1,2193 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
|
|
3
|
+
# DO NOT EDIT MANUALLY
|
|
4
|
+
# This is an autogenerated file for types exported from the `async` gem.
|
|
5
|
+
# Please instead update this file by running `bin/tapioca gem async`.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Released under the MIT License.
|
|
9
|
+
# Copyright, 2026, by Samuel Williams.
|
|
10
|
+
# Released under the MIT License.
|
|
11
|
+
# Copyright, 2018-2026, by Samuel Williams.
|
|
12
|
+
# Copyright, 2026, by Shopify Inc.
|
|
13
|
+
# Released under the MIT License.
|
|
14
|
+
# Copyright, 2024, by Samuel Williams.
|
|
15
|
+
# @namespace
|
|
16
|
+
# Released under the MIT License.
|
|
17
|
+
# Copyright, 2025-2026, by Shopify Inc.
|
|
18
|
+
# Copyright, 2025-2026, by Samuel Williams.
|
|
19
|
+
# Released under the MIT License.
|
|
20
|
+
# Copyright, 2024-2025, by Samuel Williams.
|
|
21
|
+
# Released under the MIT License.
|
|
22
|
+
# Copyright, 2022-2025, by Samuel Williams.
|
|
23
|
+
# Copyright, 2025, by Shopify Inc.
|
|
24
|
+
# Released under the MIT License.
|
|
25
|
+
# Copyright, 2025, by Samuel Williams.
|
|
26
|
+
# Released under the MIT License.
|
|
27
|
+
# Copyright, 2022-2025, by Samuel Williams.
|
|
28
|
+
# Copyright, 2024, by Patrik Wenger.
|
|
29
|
+
# Copyright, 2025, by Shopify Inc.
|
|
30
|
+
#
|
|
31
|
+
# pkg:gem/async#lib/async/version.rb:7
|
|
32
|
+
module Async; end
|
|
33
|
+
|
|
34
|
+
# 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}.
|
|
35
|
+
#
|
|
36
|
+
# @public Since *Async v1*.
|
|
37
|
+
#
|
|
38
|
+
# pkg:gem/async#lib/async/barrier.rb:15
|
|
39
|
+
class Async::Barrier
|
|
40
|
+
# Initialize the barrier.
|
|
41
|
+
# @parameter parent [Task | Semaphore | Nil] The parent for holding any children tasks.
|
|
42
|
+
# @public Since *Async v1*.
|
|
43
|
+
#
|
|
44
|
+
# pkg:gem/async#lib/async/barrier.rb:19
|
|
45
|
+
def initialize(parent: T.unsafe(nil)); end
|
|
46
|
+
|
|
47
|
+
# Execute a child task and add it to the barrier.
|
|
48
|
+
# @asynchronous Executes the given block concurrently.
|
|
49
|
+
# @returns [Task] The task which was created to execute the block.
|
|
50
|
+
#
|
|
51
|
+
# pkg:gem/async#lib/async/barrier.rb:48
|
|
52
|
+
def async(*arguments, parent: T.unsafe(nil), **options, &block); end
|
|
53
|
+
|
|
54
|
+
# Cancel all tasks held by the barrier.
|
|
55
|
+
# @asynchronous May wait for tasks to finish executing.
|
|
56
|
+
#
|
|
57
|
+
# pkg:gem/async#lib/async/barrier.rb:118
|
|
58
|
+
def cancel; end
|
|
59
|
+
|
|
60
|
+
# Whether there are any tasks being held by the barrier.
|
|
61
|
+
# @returns [Boolean]
|
|
62
|
+
#
|
|
63
|
+
# pkg:gem/async#lib/async/barrier.rb:77
|
|
64
|
+
def empty?; end
|
|
65
|
+
|
|
66
|
+
# Number of tasks being held by the barrier.
|
|
67
|
+
#
|
|
68
|
+
# pkg:gem/async#lib/async/barrier.rb:38
|
|
69
|
+
def size; end
|
|
70
|
+
|
|
71
|
+
# Backward compatibility alias for {#cancel}.
|
|
72
|
+
# @deprecated Use {#cancel} instead.
|
|
73
|
+
#
|
|
74
|
+
# pkg:gem/async#lib/async/barrier.rb:128
|
|
75
|
+
def stop; end
|
|
76
|
+
|
|
77
|
+
# All tasks which have been invoked into the barrier.
|
|
78
|
+
#
|
|
79
|
+
# pkg:gem/async#lib/async/barrier.rb:43
|
|
80
|
+
def tasks; end
|
|
81
|
+
|
|
82
|
+
# Wait for all tasks to complete by invoking {Task#wait} on each waiting task, which may raise an error. As long as the task has completed, it will be removed from the barrier.
|
|
83
|
+
#
|
|
84
|
+
# @yields {|task| ...} If a block is given, the unwaited task is yielded. You must invoke {Task#wait} yourself. In addition, you may `break` if you have captured enough results.
|
|
85
|
+
# @returns [Integer | Nil] The number of tasks which were waited for, or `nil` if there were no tasks to wait for.
|
|
86
|
+
#
|
|
87
|
+
# @asynchronous Will wait for tasks to finish executing.
|
|
88
|
+
#
|
|
89
|
+
# pkg:gem/async#lib/async/barrier.rb:87
|
|
90
|
+
def wait; end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# pkg:gem/async#lib/async/barrier.rb:27
|
|
94
|
+
class Async::Barrier::TaskNode < ::Async::List::Node
|
|
95
|
+
# pkg:gem/async#lib/async/barrier.rb:28
|
|
96
|
+
def initialize(task); end
|
|
97
|
+
|
|
98
|
+
# pkg:gem/async#lib/async/barrier.rb:32
|
|
99
|
+
def task; end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Raised when a task is explicitly cancelled.
|
|
103
|
+
#
|
|
104
|
+
# pkg:gem/async#lib/async/cancel.rb:8
|
|
105
|
+
class Async::Cancel < ::Exception
|
|
106
|
+
# Create a new cancel operation.
|
|
107
|
+
#
|
|
108
|
+
# This is a compatibility method for Ruby versions before 3.5 where cause is not propagated correctly when using {Fiber#raise}
|
|
109
|
+
#
|
|
110
|
+
# @parameter message [String | Hash] The error message or a hash containing the cause.
|
|
111
|
+
#
|
|
112
|
+
# pkg:gem/async#lib/async/cancel.rb:40
|
|
113
|
+
def initialize(message = T.unsafe(nil)); end
|
|
114
|
+
|
|
115
|
+
# @returns [Exception] The cause of the cancel operation.
|
|
116
|
+
#
|
|
117
|
+
# This is a compatibility method for Ruby versions before 3.5 where cause is not propagated correctly when using {Fiber#raise}, we explicitly capture the cause here.
|
|
118
|
+
#
|
|
119
|
+
# pkg:gem/async#lib/async/cancel.rb:53
|
|
120
|
+
def cause; end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Represents the source of the cancel operation.
|
|
124
|
+
#
|
|
125
|
+
# pkg:gem/async#lib/async/cancel.rb:10
|
|
126
|
+
class Async::Cancel::Cause < ::Exception
|
|
127
|
+
class << self
|
|
128
|
+
# @returns [Array(String)] The backtrace of the caller.
|
|
129
|
+
# @returns [Array(Thread::Backtrace::Location)] The backtrace of the caller.
|
|
130
|
+
#
|
|
131
|
+
# pkg:gem/async#lib/async/cancel.rb:13
|
|
132
|
+
def backtrace; end
|
|
133
|
+
|
|
134
|
+
# Create a new cause of the cancel operation, with the given message.
|
|
135
|
+
#
|
|
136
|
+
# @parameter message [String] The error message.
|
|
137
|
+
# @returns [Cause] The cause of the cancel operation.
|
|
138
|
+
#
|
|
139
|
+
# pkg:gem/async#lib/async/cancel.rb:27
|
|
140
|
+
def for(message = T.unsafe(nil)); end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Used to defer cancelling the current task until later.
|
|
145
|
+
#
|
|
146
|
+
# pkg:gem/async#lib/async/cancel.rb:59
|
|
147
|
+
class Async::Cancel::Later
|
|
148
|
+
# Create a new cancel later operation.
|
|
149
|
+
#
|
|
150
|
+
# @parameter task [Task] The task to cancel later.
|
|
151
|
+
# @parameter cause [Exception] The cause of the cancel operation.
|
|
152
|
+
#
|
|
153
|
+
# pkg:gem/async#lib/async/cancel.rb:64
|
|
154
|
+
def initialize(task, cause = T.unsafe(nil)); end
|
|
155
|
+
|
|
156
|
+
# @returns [Boolean] Whether the task is alive.
|
|
157
|
+
#
|
|
158
|
+
# pkg:gem/async#lib/async/cancel.rb:70
|
|
159
|
+
def alive?; end
|
|
160
|
+
|
|
161
|
+
# Transfer control to the operation - this will cancel the task.
|
|
162
|
+
#
|
|
163
|
+
# pkg:gem/async#lib/async/cancel.rb:75
|
|
164
|
+
def transfer; end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# A list of children tasks.
|
|
168
|
+
#
|
|
169
|
+
# pkg:gem/async#lib/async/node.rb:16
|
|
170
|
+
class Async::Children < ::Async::List
|
|
171
|
+
# Create an empty list of children tasks.
|
|
172
|
+
#
|
|
173
|
+
# pkg:gem/async#lib/async/node.rb:18
|
|
174
|
+
def initialize; end
|
|
175
|
+
|
|
176
|
+
# Adjust the number of transient children, assuming it has changed.
|
|
177
|
+
#
|
|
178
|
+
# Despite being public, this is not intended to be called directly. It is used internally by {Node#transient=}.
|
|
179
|
+
#
|
|
180
|
+
# @parameter transient [Boolean] Whether to increment or decrement the transient count.
|
|
181
|
+
#
|
|
182
|
+
# pkg:gem/async#lib/async/node.rb:44
|
|
183
|
+
def adjust_transient_count(transient); end
|
|
184
|
+
|
|
185
|
+
# Whether all children are considered finished. Ignores transient children.
|
|
186
|
+
#
|
|
187
|
+
# pkg:gem/async#lib/async/node.rb:30
|
|
188
|
+
def finished?; end
|
|
189
|
+
|
|
190
|
+
# Whether the children is empty, preserved for compatibility.
|
|
191
|
+
#
|
|
192
|
+
# pkg:gem/async#lib/async/node.rb:35
|
|
193
|
+
def nil?; end
|
|
194
|
+
|
|
195
|
+
# Some children may be marked as transient. Transient children do not prevent the parent from finishing.
|
|
196
|
+
# @returns [Boolean] Whether the node has transient children.
|
|
197
|
+
#
|
|
198
|
+
# pkg:gem/async#lib/async/node.rb:25
|
|
199
|
+
def transients?; end
|
|
200
|
+
|
|
201
|
+
private
|
|
202
|
+
|
|
203
|
+
# pkg:gem/async#lib/async/node.rb:54
|
|
204
|
+
def added(node); end
|
|
205
|
+
|
|
206
|
+
# pkg:gem/async#lib/async/node.rb:62
|
|
207
|
+
def removed(node); end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# A convenient wrapper around the internal monotonic clock.
|
|
211
|
+
# @public Since *Async v1*.
|
|
212
|
+
#
|
|
213
|
+
# pkg:gem/async#lib/async/clock.rb:10
|
|
214
|
+
class Async::Clock
|
|
215
|
+
# Create a new clock with the initial total time.
|
|
216
|
+
# @parameter total [Numeric] The initial clock duration.
|
|
217
|
+
#
|
|
218
|
+
# pkg:gem/async#lib/async/clock.rb:35
|
|
219
|
+
def initialize(total = T.unsafe(nil)); end
|
|
220
|
+
|
|
221
|
+
# Convert the clock to a JSON-compatible hash.
|
|
222
|
+
#
|
|
223
|
+
# @returns [Hash] The JSON-compatible hash.
|
|
224
|
+
#
|
|
225
|
+
# pkg:gem/async#lib/async/clock.rb:81
|
|
226
|
+
def as_json(*, **, &); end
|
|
227
|
+
|
|
228
|
+
# Reset the total elapsed time. If the clock is currently running, reset the start time to now.
|
|
229
|
+
#
|
|
230
|
+
# pkg:gem/async#lib/async/clock.rb:70
|
|
231
|
+
def reset!; end
|
|
232
|
+
|
|
233
|
+
# Start measuring a duration.
|
|
234
|
+
#
|
|
235
|
+
# pkg:gem/async#lib/async/clock.rb:44
|
|
236
|
+
def start!; end
|
|
237
|
+
|
|
238
|
+
# @returns [Numeric | Nil] The time when the clock was started, or nil if not started.
|
|
239
|
+
#
|
|
240
|
+
# pkg:gem/async#lib/async/clock.rb:41
|
|
241
|
+
def started; end
|
|
242
|
+
|
|
243
|
+
# Stop measuring a duration and append the duration to the current total.
|
|
244
|
+
#
|
|
245
|
+
# pkg:gem/async#lib/async/clock.rb:49
|
|
246
|
+
def stop!; end
|
|
247
|
+
|
|
248
|
+
# Convert the clock to a JSON string.
|
|
249
|
+
#
|
|
250
|
+
# @returns [String] The JSON string.
|
|
251
|
+
#
|
|
252
|
+
# pkg:gem/async#lib/async/clock.rb:91
|
|
253
|
+
def to_json(*, **, &); end
|
|
254
|
+
|
|
255
|
+
# The total elapsed time including any current duration.
|
|
256
|
+
#
|
|
257
|
+
# pkg:gem/async#lib/async/clock.rb:59
|
|
258
|
+
def total; end
|
|
259
|
+
|
|
260
|
+
class << self
|
|
261
|
+
# Measure the execution of a block of code.
|
|
262
|
+
# @yields {...} The block to execute.
|
|
263
|
+
# @returns [Numeric] The total execution time.
|
|
264
|
+
#
|
|
265
|
+
# pkg:gem/async#lib/async/clock.rb:19
|
|
266
|
+
def measure; end
|
|
267
|
+
|
|
268
|
+
# Get the current elapsed monotonic time.
|
|
269
|
+
#
|
|
270
|
+
# pkg:gem/async#lib/async/clock.rb:12
|
|
271
|
+
def now; end
|
|
272
|
+
|
|
273
|
+
# Start measuring elapsed time from now.
|
|
274
|
+
# @returns [Clock]
|
|
275
|
+
#
|
|
276
|
+
# pkg:gem/async#lib/async/clock.rb:29
|
|
277
|
+
def start; end
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
# A synchronization primitive, which allows fibers to wait until a particular condition is (edge) triggered.
|
|
282
|
+
# @public Since *Async v1*.
|
|
283
|
+
#
|
|
284
|
+
# pkg:gem/async#lib/async/condition.rb:14
|
|
285
|
+
class Async::Condition
|
|
286
|
+
# Create a new condition.
|
|
287
|
+
#
|
|
288
|
+
# pkg:gem/async#lib/async/condition.rb:16
|
|
289
|
+
def initialize; end
|
|
290
|
+
|
|
291
|
+
# @returns [Boolean] If there are no fibers waiting on this condition.
|
|
292
|
+
#
|
|
293
|
+
# pkg:gem/async#lib/async/condition.rb:27
|
|
294
|
+
def empty?; end
|
|
295
|
+
|
|
296
|
+
# Signal to a given task that it should resume operations.
|
|
297
|
+
# @parameter value [Object | Nil] The value to return to the waiting fibers.
|
|
298
|
+
#
|
|
299
|
+
# pkg:gem/async#lib/async/condition.rb:43
|
|
300
|
+
def signal(value = T.unsafe(nil)); end
|
|
301
|
+
|
|
302
|
+
# Queue up the current fiber and wait on yielding the task.
|
|
303
|
+
# @returns [Object]
|
|
304
|
+
#
|
|
305
|
+
# pkg:gem/async#lib/async/condition.rb:22
|
|
306
|
+
def wait; end
|
|
307
|
+
|
|
308
|
+
# @returns [Boolean] Is any fiber waiting on this notification?
|
|
309
|
+
#
|
|
310
|
+
# pkg:gem/async#lib/async/condition.rb:32
|
|
311
|
+
def waiting?; end
|
|
312
|
+
|
|
313
|
+
# @returns [Integer] Number of fibers waiting on this condition.
|
|
314
|
+
#
|
|
315
|
+
# pkg:gem/async#lib/async/condition.rb:37
|
|
316
|
+
def waiting_count; end
|
|
317
|
+
|
|
318
|
+
protected
|
|
319
|
+
|
|
320
|
+
# pkg:gem/async#lib/async/condition.rb:59
|
|
321
|
+
def exchange; end
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
# Represents a deadline timeout with decrementing remaining time.
|
|
325
|
+
# Includes an efficient representation for zero (non-blocking) timeouts.
|
|
326
|
+
# @public Since *Async v2.31*.
|
|
327
|
+
#
|
|
328
|
+
# pkg:gem/async#lib/async/deadline.rb:14
|
|
329
|
+
class Async::Deadline
|
|
330
|
+
# Create a new deadline with the specified remaining time.
|
|
331
|
+
# @parameter remaining [Numeric] The initial remaining time.
|
|
332
|
+
#
|
|
333
|
+
# pkg:gem/async#lib/async/deadline.rb:46
|
|
334
|
+
def initialize(remaining); end
|
|
335
|
+
|
|
336
|
+
# Check if the deadline has expired.
|
|
337
|
+
# @returns [Boolean] True if no time remains.
|
|
338
|
+
#
|
|
339
|
+
# pkg:gem/async#lib/async/deadline.rb:67
|
|
340
|
+
def expired?; end
|
|
341
|
+
|
|
342
|
+
# Get the remaining time, updating internal state.
|
|
343
|
+
# Each call to this method advances the internal clock and reduces
|
|
344
|
+
# the remaining time by the elapsed duration since the last call.
|
|
345
|
+
# @returns [Numeric] The remaining time (may be negative if expired).
|
|
346
|
+
#
|
|
347
|
+
# pkg:gem/async#lib/async/deadline.rb:55
|
|
348
|
+
def remaining; end
|
|
349
|
+
|
|
350
|
+
class << self
|
|
351
|
+
# Create a deadline for the given timeout.
|
|
352
|
+
# @parameter timeout [Numeric | Nil] The timeout duration, or nil for no timeout.
|
|
353
|
+
# @returns [Deadline | Nil] A deadline instance, Zero singleton, or nil.
|
|
354
|
+
#
|
|
355
|
+
# pkg:gem/async#lib/async/deadline.rb:34
|
|
356
|
+
def start(timeout); end
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# Singleton module for immediate timeouts (zero or negative).
|
|
361
|
+
# Avoids object allocation for fast path (non-blocking) timeouts.
|
|
362
|
+
#
|
|
363
|
+
# pkg:gem/async#lib/async/deadline.rb:17
|
|
364
|
+
module Async::Deadline::Zero
|
|
365
|
+
class << self
|
|
366
|
+
# Check if the deadline has expired.
|
|
367
|
+
# @returns [Boolean] Always returns true since zero timeouts are immediately expired.
|
|
368
|
+
#
|
|
369
|
+
# pkg:gem/async#lib/async/deadline.rb:20
|
|
370
|
+
def expired?; end
|
|
371
|
+
|
|
372
|
+
# Get the remaining time.
|
|
373
|
+
# @returns [Integer] Always returns 0 since zero timeouts have no remaining time.
|
|
374
|
+
#
|
|
375
|
+
# pkg:gem/async#lib/async/deadline.rb:26
|
|
376
|
+
def remaining; end
|
|
377
|
+
end
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
# Private module that hooks into Process._fork to handle fork events.
|
|
381
|
+
#
|
|
382
|
+
# If `Scheduler#process_fork` hook is adopted in Ruby 4, this code can be removed after Ruby < 4 is no longer supported.
|
|
383
|
+
#
|
|
384
|
+
# pkg:gem/async#lib/async/fork_handler.rb:11
|
|
385
|
+
module Async::ForkHandler
|
|
386
|
+
# pkg:gem/async#lib/async/fork_handler.rb:12
|
|
387
|
+
def _fork(&block); end
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
# A load balancing mechanism that can be used process work when the system is idle.
|
|
391
|
+
#
|
|
392
|
+
# pkg:gem/async#lib/async/idler.rb:8
|
|
393
|
+
class Async::Idler
|
|
394
|
+
# Create a new idler.
|
|
395
|
+
#
|
|
396
|
+
# @public Since *Async v2*.
|
|
397
|
+
#
|
|
398
|
+
# @parameter maximum_load [Numeric] The maximum load before we start shedding work.
|
|
399
|
+
# @parameter backoff [Numeric] The initial backoff time, used for delaying work.
|
|
400
|
+
# @parameter parent [Interface(:async) | Nil] The parent task to use for async operations.
|
|
401
|
+
#
|
|
402
|
+
# pkg:gem/async#lib/async/idler.rb:16
|
|
403
|
+
def initialize(maximum_load = T.unsafe(nil), backoff: T.unsafe(nil), parent: T.unsafe(nil)); end
|
|
404
|
+
|
|
405
|
+
# Wait until the system is idle, then execute the given block in a new task.
|
|
406
|
+
#
|
|
407
|
+
# @asynchronous Executes the given block concurrently.
|
|
408
|
+
#
|
|
409
|
+
# @parameter arguments [Array] The arguments to pass to the block.
|
|
410
|
+
# @parameter parent [Interface(:async) | Nil] The parent task to use for async operations.
|
|
411
|
+
# @parameter options [Hash] The options to pass to the task.
|
|
412
|
+
# @yields {|task| ...} When the system is idle, the block will be executed in a new task.
|
|
413
|
+
#
|
|
414
|
+
# pkg:gem/async#lib/async/idler.rb:33
|
|
415
|
+
def async(*arguments, parent: T.unsafe(nil), **options, &block); end
|
|
416
|
+
|
|
417
|
+
# Wait until the system is idle, according to the maximum load specified.
|
|
418
|
+
#
|
|
419
|
+
# If the scheduler is overloaded, this method will sleep for an exponentially increasing amount of time.
|
|
420
|
+
#
|
|
421
|
+
# pkg:gem/async#lib/async/idler.rb:43
|
|
422
|
+
def wait; end
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
# A thread-safe queue which limits the number of items that can be enqueued.
|
|
426
|
+
#
|
|
427
|
+
# @public Since *Async v1*.
|
|
428
|
+
#
|
|
429
|
+
# pkg:gem/async#lib/async/queue.rb:129
|
|
430
|
+
class Async::LimitedQueue < ::Async::Queue
|
|
431
|
+
# Create a new limited queue.
|
|
432
|
+
#
|
|
433
|
+
# @parameter limit [Integer] The maximum number of items that can be enqueued.
|
|
434
|
+
# @parameter full [Notification] The notification to use for signaling when the queue is full. (ignored, for compatibility)
|
|
435
|
+
#
|
|
436
|
+
# pkg:gem/async#lib/async/queue.rb:141
|
|
437
|
+
def initialize(limit = T.unsafe(nil), **options); end
|
|
438
|
+
|
|
439
|
+
# @attribute [Integer] The maximum number of items that can be enqueued.
|
|
440
|
+
#
|
|
441
|
+
# pkg:gem/async#lib/async/queue.rb:146
|
|
442
|
+
def limit; end
|
|
443
|
+
|
|
444
|
+
# @returns [Boolean] Whether trying to enqueue an item would block.
|
|
445
|
+
#
|
|
446
|
+
# pkg:gem/async#lib/async/queue.rb:151
|
|
447
|
+
def limited?; end
|
|
448
|
+
|
|
449
|
+
class << self
|
|
450
|
+
# @private This exists purely for emitting a warning.
|
|
451
|
+
#
|
|
452
|
+
# pkg:gem/async#lib/async/queue.rb:131
|
|
453
|
+
def new(*, **, &); end
|
|
454
|
+
end
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
# A general doublely linked list. This is used internally by {Async::Barrier} and {Async::Condition} to manage child tasks.
|
|
458
|
+
#
|
|
459
|
+
# pkg:gem/async#lib/async/list.rb:9
|
|
460
|
+
class Async::List
|
|
461
|
+
# Initialize a new, empty, list.
|
|
462
|
+
#
|
|
463
|
+
# pkg:gem/async#lib/async/list.rb:11
|
|
464
|
+
def initialize; end
|
|
465
|
+
|
|
466
|
+
# A callback that is invoked when an item is added to the list.
|
|
467
|
+
#
|
|
468
|
+
# pkg:gem/async#lib/async/list.rb:51
|
|
469
|
+
def added(node); end
|
|
470
|
+
|
|
471
|
+
# Append a node to the end of the list.
|
|
472
|
+
#
|
|
473
|
+
# pkg:gem/async#lib/async/list.rb:57
|
|
474
|
+
def append(node); end
|
|
475
|
+
|
|
476
|
+
# Iterate over each node in the linked list. It is generally safe to remove the current node, any previous node or any future node during iteration.
|
|
477
|
+
#
|
|
478
|
+
# @yields {|node| ...} Yields each node in the list.
|
|
479
|
+
# @returns [List] Returns self.
|
|
480
|
+
#
|
|
481
|
+
# pkg:gem/async#lib/async/list.rb:177
|
|
482
|
+
def each(&block); end
|
|
483
|
+
|
|
484
|
+
# @returns [Boolean] True if the list is empty.
|
|
485
|
+
#
|
|
486
|
+
# pkg:gem/async#lib/async/list.rb:140
|
|
487
|
+
def empty?; end
|
|
488
|
+
|
|
489
|
+
# @returns [Node] Returns the first node in the list, if it is not empty.
|
|
490
|
+
#
|
|
491
|
+
# pkg:gem/async#lib/async/list.rb:198
|
|
492
|
+
def first; end
|
|
493
|
+
|
|
494
|
+
# @attribute [Node | Nil] Points at the end of the list.
|
|
495
|
+
#
|
|
496
|
+
# pkg:gem/async#lib/async/list.rb:42
|
|
497
|
+
def head; end
|
|
498
|
+
|
|
499
|
+
# @attribute [Node | Nil] Points at the end of the list.
|
|
500
|
+
#
|
|
501
|
+
# pkg:gem/async#lib/async/list.rb:42
|
|
502
|
+
def head=(_arg0); end
|
|
503
|
+
|
|
504
|
+
# Determine whether the given node is included in the list.
|
|
505
|
+
#
|
|
506
|
+
# @parameter needle [Node] The node to search for.
|
|
507
|
+
# @returns [Boolean] Returns true if the node is in the list.
|
|
508
|
+
#
|
|
509
|
+
# pkg:gem/async#lib/async/list.rb:189
|
|
510
|
+
def include?(needle); end
|
|
511
|
+
|
|
512
|
+
# @returns [String] A short summary of the list.
|
|
513
|
+
#
|
|
514
|
+
# pkg:gem/async#lib/async/list.rb:23
|
|
515
|
+
def inspect; end
|
|
516
|
+
|
|
517
|
+
# @returns [Node] Returns the last node in the list, if it is not empty.
|
|
518
|
+
#
|
|
519
|
+
# pkg:gem/async#lib/async/list.rb:215
|
|
520
|
+
def last; end
|
|
521
|
+
|
|
522
|
+
# Prepend a node to the start of the list.
|
|
523
|
+
#
|
|
524
|
+
# pkg:gem/async#lib/async/list.rb:71
|
|
525
|
+
def prepend(node); end
|
|
526
|
+
|
|
527
|
+
# Remove the node. If it was already removed, this will raise an error.
|
|
528
|
+
#
|
|
529
|
+
# You should be careful to only remove nodes that are part of this list.
|
|
530
|
+
#
|
|
531
|
+
# @raises [ArgumentError] If the node is not part of this list.
|
|
532
|
+
# @returns [Node] Returns the node if it was removed, otherwise nil.
|
|
533
|
+
#
|
|
534
|
+
# pkg:gem/async#lib/async/list.rb:119
|
|
535
|
+
def remove(node); end
|
|
536
|
+
|
|
537
|
+
# Remove the node if it is in a list.
|
|
538
|
+
#
|
|
539
|
+
# You should be careful to only remove nodes that are part of this list.
|
|
540
|
+
#
|
|
541
|
+
# @returns [Node] Returns the node if it was removed, otherwise nil.
|
|
542
|
+
#
|
|
543
|
+
# pkg:gem/async#lib/async/list.rb:105
|
|
544
|
+
def remove?(node); end
|
|
545
|
+
|
|
546
|
+
# A callback that is invoked when an item is removed from the list.
|
|
547
|
+
#
|
|
548
|
+
# pkg:gem/async#lib/async/list.rb:95
|
|
549
|
+
def removed(node); end
|
|
550
|
+
|
|
551
|
+
# Shift the first node off the list, if it is not empty.
|
|
552
|
+
#
|
|
553
|
+
# pkg:gem/async#lib/async/list.rb:232
|
|
554
|
+
def shift; end
|
|
555
|
+
|
|
556
|
+
# @attribute [Integer] The number of nodes in the list.
|
|
557
|
+
#
|
|
558
|
+
# pkg:gem/async#lib/async/list.rb:48
|
|
559
|
+
def size; end
|
|
560
|
+
|
|
561
|
+
# Add the node, yield, and the remove the node.
|
|
562
|
+
# @yields {|node| ...} Yields the node.
|
|
563
|
+
# @returns [Object] Returns the result of the block.
|
|
564
|
+
#
|
|
565
|
+
# pkg:gem/async#lib/async/list.rb:87
|
|
566
|
+
def stack(node, &block); end
|
|
567
|
+
|
|
568
|
+
# @attribute [Node | Nil] Points at the start of the list.
|
|
569
|
+
#
|
|
570
|
+
# pkg:gem/async#lib/async/list.rb:45
|
|
571
|
+
def tail; end
|
|
572
|
+
|
|
573
|
+
# @attribute [Node | Nil] Points at the start of the list.
|
|
574
|
+
#
|
|
575
|
+
# pkg:gem/async#lib/async/list.rb:45
|
|
576
|
+
def tail=(_arg0); end
|
|
577
|
+
|
|
578
|
+
# Fast, safe, unbounded accumulation of children.
|
|
579
|
+
#
|
|
580
|
+
# pkg:gem/async#lib/async/list.rb:26
|
|
581
|
+
def to_a; end
|
|
582
|
+
|
|
583
|
+
# @returns [String] A short summary of the list.
|
|
584
|
+
#
|
|
585
|
+
# pkg:gem/async#lib/async/list.rb:18
|
|
586
|
+
def to_s; end
|
|
587
|
+
|
|
588
|
+
private
|
|
589
|
+
|
|
590
|
+
# pkg:gem/async#lib/async/list.rb:128
|
|
591
|
+
def remove!(node); end
|
|
592
|
+
end
|
|
593
|
+
|
|
594
|
+
# pkg:gem/async#lib/async/list.rb:252
|
|
595
|
+
class Async::List::Iterator < ::Async::List::Node
|
|
596
|
+
# pkg:gem/async#lib/async/list.rb:253
|
|
597
|
+
def initialize(list); end
|
|
598
|
+
|
|
599
|
+
# pkg:gem/async#lib/async/list.rb:296
|
|
600
|
+
def each; end
|
|
601
|
+
|
|
602
|
+
# pkg:gem/async#lib/async/list.rb:281
|
|
603
|
+
def move_current; end
|
|
604
|
+
|
|
605
|
+
# pkg:gem/async#lib/async/list.rb:271
|
|
606
|
+
def move_next; end
|
|
607
|
+
|
|
608
|
+
# pkg:gem/async#lib/async/list.rb:263
|
|
609
|
+
def remove!; end
|
|
610
|
+
|
|
611
|
+
class << self
|
|
612
|
+
# pkg:gem/async#lib/async/list.rb:306
|
|
613
|
+
def each(list, &block); end
|
|
614
|
+
end
|
|
615
|
+
end
|
|
616
|
+
|
|
617
|
+
# A linked list Node.
|
|
618
|
+
#
|
|
619
|
+
# pkg:gem/async#lib/async/list.rb:239
|
|
620
|
+
class Async::List::Node
|
|
621
|
+
# pkg:gem/async#lib/async/list.rb:240
|
|
622
|
+
def head; end
|
|
623
|
+
|
|
624
|
+
# pkg:gem/async#lib/async/list.rb:240
|
|
625
|
+
def head=(_arg0); end
|
|
626
|
+
|
|
627
|
+
# @returns [String] A string representation of the node.
|
|
628
|
+
#
|
|
629
|
+
# pkg:gem/async#lib/async/list.rb:249
|
|
630
|
+
def inspect; end
|
|
631
|
+
|
|
632
|
+
# pkg:gem/async#lib/async/list.rb:241
|
|
633
|
+
def tail; end
|
|
634
|
+
|
|
635
|
+
# pkg:gem/async#lib/async/list.rb:241
|
|
636
|
+
def tail=(_arg0); end
|
|
637
|
+
|
|
638
|
+
# @returns [String] A string representation of the node.
|
|
639
|
+
#
|
|
640
|
+
# pkg:gem/async#lib/async/list.rb:244
|
|
641
|
+
def to_s; end
|
|
642
|
+
end
|
|
643
|
+
|
|
644
|
+
# @namespace
|
|
645
|
+
#
|
|
646
|
+
# pkg:gem/async#lib/async/loop.rb:10
|
|
647
|
+
module Async::Loop
|
|
648
|
+
class << self
|
|
649
|
+
# Execute a block repeatedly with a fixed delay between executions.
|
|
650
|
+
#
|
|
651
|
+
# Unlike {quantized}, this method waits for the specified interval *after* each execution
|
|
652
|
+
# completes. This means the actual time between the start of successive executions will be
|
|
653
|
+
# `interval + execution_time`.
|
|
654
|
+
#
|
|
655
|
+
# If an error occurs during block execution, it is logged and the loop continues.
|
|
656
|
+
#
|
|
657
|
+
# @example Run every 5 seconds (plus execution time):
|
|
658
|
+
# Async::Loop.periodic(interval: 5) do
|
|
659
|
+
# process_queue
|
|
660
|
+
# end
|
|
661
|
+
#
|
|
662
|
+
# @parameter interval [Numeric] The delay in seconds between executions.
|
|
663
|
+
# @yields The block to execute periodically.
|
|
664
|
+
#
|
|
665
|
+
# @public Since *Async v2.37*.
|
|
666
|
+
#
|
|
667
|
+
# pkg:gem/async#lib/async/loop.rb:72
|
|
668
|
+
def periodic(interval: T.unsafe(nil), &block); end
|
|
669
|
+
|
|
670
|
+
# Execute a block repeatedly at quantized (time-aligned) intervals.
|
|
671
|
+
#
|
|
672
|
+
# The alignment is computed modulo the current clock time in seconds. For example, with
|
|
673
|
+
# `interval: 60`, executions will occur at 00:00, 01:00, 02:00, etc., regardless of when
|
|
674
|
+
# the loop is started. With `interval: 300` (5 minutes), executions align to 00:00, 00:05,
|
|
675
|
+
# 00:10, etc.
|
|
676
|
+
#
|
|
677
|
+
# This is particularly useful for tasks that should run at predictable wall-clock times,
|
|
678
|
+
# such as metrics collection, periodic cleanup, or scheduled jobs that need to align
|
|
679
|
+
# across multiple processes.
|
|
680
|
+
#
|
|
681
|
+
# If an error occurs during block execution, it is logged and the loop continues.
|
|
682
|
+
#
|
|
683
|
+
# @example Run every minute at :00 seconds:
|
|
684
|
+
# Async::Loop.quantized(interval: 60) do
|
|
685
|
+
# puts "Current time: #{Time.now}"
|
|
686
|
+
# end
|
|
687
|
+
#
|
|
688
|
+
# @example Run every 5 minutes aligned to the hour:
|
|
689
|
+
# Async::Loop.quantized(interval: 300) do
|
|
690
|
+
# collect_metrics
|
|
691
|
+
# end
|
|
692
|
+
#
|
|
693
|
+
# @parameter interval [Numeric] The interval in seconds. Executions will align to multiples of this interval based on the current time.
|
|
694
|
+
# @yields The block to execute at each interval.
|
|
695
|
+
#
|
|
696
|
+
# @public Since *Async v2.37*.
|
|
697
|
+
#
|
|
698
|
+
# pkg:gem/async#lib/async/loop.rb:38
|
|
699
|
+
def quantized(interval: T.unsafe(nil), &block); end
|
|
700
|
+
end
|
|
701
|
+
end
|
|
702
|
+
|
|
703
|
+
# A node in a tree, used for implementing the task hierarchy.
|
|
704
|
+
#
|
|
705
|
+
# pkg:gem/async#lib/async/node.rb:72
|
|
706
|
+
class Async::Node
|
|
707
|
+
# Create a new node in the tree.
|
|
708
|
+
# @parameter parent [Node | Nil] This node will attach to the given parent.
|
|
709
|
+
#
|
|
710
|
+
# pkg:gem/async#lib/async/node.rb:75
|
|
711
|
+
def initialize(parent = T.unsafe(nil), annotation: T.unsafe(nil), transient: T.unsafe(nil)); end
|
|
712
|
+
|
|
713
|
+
# Annotate the node with a description.
|
|
714
|
+
#
|
|
715
|
+
# @parameter annotation [String] The description to annotate the node with.
|
|
716
|
+
#
|
|
717
|
+
# pkg:gem/async#lib/async/node.rb:144
|
|
718
|
+
def annotate(annotation); end
|
|
719
|
+
|
|
720
|
+
# @attribute [String | Nil] A useful identifier for the current node.
|
|
721
|
+
#
|
|
722
|
+
# pkg:gem/async#lib/async/node.rb:110
|
|
723
|
+
def annotation; end
|
|
724
|
+
|
|
725
|
+
# Provides a backtrace for nodes that have an active execution context.
|
|
726
|
+
#
|
|
727
|
+
# @returns [Array(Thread::Backtrace::Locations) | Nil] The backtrace of the node, if available.
|
|
728
|
+
#
|
|
729
|
+
# pkg:gem/async#lib/async/node.rb:176
|
|
730
|
+
def backtrace(*arguments); end
|
|
731
|
+
|
|
732
|
+
# Attempt to cancel the current node immediately, including all non-transient children. Invokes {#stop_children} to cancel all children.
|
|
733
|
+
#
|
|
734
|
+
# @parameter later [Boolean] Whether to defer cancelling until some point in the future.
|
|
735
|
+
# @parameter cause [Exception | Nil] The cause of the cancel operation.
|
|
736
|
+
#
|
|
737
|
+
# pkg:gem/async#lib/async/node.rb:288
|
|
738
|
+
def cancel(later = T.unsafe(nil), cause: T.unsafe(nil)); end
|
|
739
|
+
|
|
740
|
+
# Whether the node has been cancelled.
|
|
741
|
+
#
|
|
742
|
+
# pkg:gem/async#lib/async/node.rb:313
|
|
743
|
+
def cancelled?; end
|
|
744
|
+
|
|
745
|
+
# @attribute [Children | Nil] Optional list of children.
|
|
746
|
+
#
|
|
747
|
+
# pkg:gem/async#lib/async/node.rb:107
|
|
748
|
+
def children; end
|
|
749
|
+
|
|
750
|
+
# Whether this node has any children.
|
|
751
|
+
# @returns [Boolean]
|
|
752
|
+
#
|
|
753
|
+
# pkg:gem/async#lib/async/node.rb:114
|
|
754
|
+
def children?; end
|
|
755
|
+
|
|
756
|
+
# If the node has a parent, and is {finished?}, then remove this node from
|
|
757
|
+
# the parent.
|
|
758
|
+
#
|
|
759
|
+
# pkg:gem/async#lib/async/node.rb:232
|
|
760
|
+
def consume; end
|
|
761
|
+
|
|
762
|
+
# A description of the node, including the annotation and object name.
|
|
763
|
+
#
|
|
764
|
+
# @returns [String] The description of the node.
|
|
765
|
+
#
|
|
766
|
+
# pkg:gem/async#lib/async/node.rb:161
|
|
767
|
+
def description; end
|
|
768
|
+
|
|
769
|
+
# Whether the node can be consumed (deleted) safely. By default, checks if the children set is empty.
|
|
770
|
+
#
|
|
771
|
+
# @returns [Boolean]
|
|
772
|
+
#
|
|
773
|
+
# pkg:gem/async#lib/async/node.rb:226
|
|
774
|
+
def finished?; end
|
|
775
|
+
|
|
776
|
+
# @private
|
|
777
|
+
#
|
|
778
|
+
# pkg:gem/async#lib/async/node.rb:98
|
|
779
|
+
def head; end
|
|
780
|
+
|
|
781
|
+
# @private
|
|
782
|
+
#
|
|
783
|
+
# pkg:gem/async#lib/async/node.rb:98
|
|
784
|
+
def head=(_arg0); end
|
|
785
|
+
|
|
786
|
+
# @returns [String] A description of the node.
|
|
787
|
+
#
|
|
788
|
+
# pkg:gem/async#lib/async/node.rb:186
|
|
789
|
+
def inspect; end
|
|
790
|
+
|
|
791
|
+
# @attribute [Node] The parent node.
|
|
792
|
+
#
|
|
793
|
+
# pkg:gem/async#lib/async/node.rb:104
|
|
794
|
+
def parent; end
|
|
795
|
+
|
|
796
|
+
# Change the parent of this node.
|
|
797
|
+
#
|
|
798
|
+
# @parameter parent [Node | Nil] The parent to attach to, or nil to detach.
|
|
799
|
+
# @returns [Node] Itself.
|
|
800
|
+
#
|
|
801
|
+
# pkg:gem/async#lib/async/node.rb:192
|
|
802
|
+
def parent=(parent); end
|
|
803
|
+
|
|
804
|
+
# Print the hierarchy of the task tree from the given node.
|
|
805
|
+
#
|
|
806
|
+
# @parameter out [IO] The output stream to write to.
|
|
807
|
+
# @parameter backtrace [Boolean] Whether to print the backtrace of each node.
|
|
808
|
+
#
|
|
809
|
+
# pkg:gem/async#lib/async/node.rb:327
|
|
810
|
+
def print_hierarchy(out = T.unsafe(nil), backtrace: T.unsafe(nil)); end
|
|
811
|
+
|
|
812
|
+
# @returns [Node] The root node in the hierarchy.
|
|
813
|
+
#
|
|
814
|
+
# pkg:gem/async#lib/async/node.rb:93
|
|
815
|
+
def root; end
|
|
816
|
+
|
|
817
|
+
# Backward compatibility alias for {#cancel}.
|
|
818
|
+
# @deprecated Use {#cancel} instead.
|
|
819
|
+
#
|
|
820
|
+
# pkg:gem/async#lib/async/node.rb:295
|
|
821
|
+
def stop(*, **, &); end
|
|
822
|
+
|
|
823
|
+
# Backward compatibility alias for {#cancelled?}.
|
|
824
|
+
# @deprecated Use {#cancelled?} instead.
|
|
825
|
+
#
|
|
826
|
+
# pkg:gem/async#lib/async/node.rb:319
|
|
827
|
+
def stopped?; end
|
|
828
|
+
|
|
829
|
+
# @private
|
|
830
|
+
#
|
|
831
|
+
# pkg:gem/async#lib/async/node.rb:101
|
|
832
|
+
def tail; end
|
|
833
|
+
|
|
834
|
+
# @private
|
|
835
|
+
#
|
|
836
|
+
# pkg:gem/async#lib/async/node.rb:101
|
|
837
|
+
def tail=(_arg0); end
|
|
838
|
+
|
|
839
|
+
# Immediately terminate all children tasks, including transient tasks. Internally invokes `stop(false)` on all children. This should be considered a last ditch effort and is used when closing the scheduler.
|
|
840
|
+
#
|
|
841
|
+
# pkg:gem/async#lib/async/node.rb:272
|
|
842
|
+
def terminate; end
|
|
843
|
+
|
|
844
|
+
# @returns [String] A description of the node.
|
|
845
|
+
#
|
|
846
|
+
# pkg:gem/async#lib/async/node.rb:181
|
|
847
|
+
def to_s; end
|
|
848
|
+
|
|
849
|
+
# Change the transient state of the node.
|
|
850
|
+
#
|
|
851
|
+
# A transient node is not considered when determining if a node is finished, and propagates up if the parent is consumed.
|
|
852
|
+
#
|
|
853
|
+
# @parameter value [Boolean] Whether the node is transient.
|
|
854
|
+
#
|
|
855
|
+
# pkg:gem/async#lib/async/node.rb:133
|
|
856
|
+
def transient=(value); end
|
|
857
|
+
|
|
858
|
+
# Represents whether a node is transient. Transient nodes are not considered
|
|
859
|
+
# when determining if a node is finished. This is useful for tasks which are
|
|
860
|
+
# internal to an object rather than explicit user concurrency. For example,
|
|
861
|
+
# a child task which is pruning a connection pool is transient, because it
|
|
862
|
+
# is not directly related to the parent task, and should not prevent the
|
|
863
|
+
# parent task from finishing.
|
|
864
|
+
#
|
|
865
|
+
# pkg:gem/async#lib/async/node.rb:124
|
|
866
|
+
def transient?; end
|
|
867
|
+
|
|
868
|
+
# Traverse the task tree.
|
|
869
|
+
#
|
|
870
|
+
# @returns [Enumerator] An enumerator which will traverse the tree if no block is given.
|
|
871
|
+
# @yields {|node, level| ...} The node and the level relative to the given root.
|
|
872
|
+
#
|
|
873
|
+
# pkg:gem/async#lib/async/node.rb:257
|
|
874
|
+
def traverse(&block); end
|
|
875
|
+
|
|
876
|
+
# Wait for this node to complete. By default, nodes cannot be waited on.
|
|
877
|
+
# Subclasses like Task override this method to provide waiting functionality.
|
|
878
|
+
#
|
|
879
|
+
# pkg:gem/async#lib/async/node.rb:308
|
|
880
|
+
def wait; end
|
|
881
|
+
|
|
882
|
+
protected
|
|
883
|
+
|
|
884
|
+
# pkg:gem/async#lib/async/node.rb:211
|
|
885
|
+
def add_child(child); end
|
|
886
|
+
|
|
887
|
+
# pkg:gem/async#lib/async/node.rb:217
|
|
888
|
+
def remove_child(child); end
|
|
889
|
+
|
|
890
|
+
# pkg:gem/async#lib/async/node.rb:207
|
|
891
|
+
def set_parent(parent); end
|
|
892
|
+
|
|
893
|
+
# pkg:gem/async#lib/async/node.rb:263
|
|
894
|
+
def traverse_recurse(level = T.unsafe(nil), &block); end
|
|
895
|
+
|
|
896
|
+
private
|
|
897
|
+
|
|
898
|
+
# pkg:gem/async#lib/async/node.rb:339
|
|
899
|
+
def print_backtrace(out, indent, node); end
|
|
900
|
+
|
|
901
|
+
# Attempt to stop all non-transient children.
|
|
902
|
+
#
|
|
903
|
+
# pkg:gem/async#lib/async/node.rb:300
|
|
904
|
+
def stop_children(later = T.unsafe(nil), cause:); end
|
|
905
|
+
end
|
|
906
|
+
|
|
907
|
+
# 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.
|
|
908
|
+
# @public Since *Async v1*.
|
|
909
|
+
#
|
|
910
|
+
# pkg:gem/async#lib/async/notification.rb:11
|
|
911
|
+
class Async::Notification < ::Async::Condition
|
|
912
|
+
# Signal to a given task that it should resume operations.
|
|
913
|
+
#
|
|
914
|
+
# @returns [Boolean] if a task was signalled.
|
|
915
|
+
#
|
|
916
|
+
# pkg:gem/async#lib/async/notification.rb:15
|
|
917
|
+
def signal(value = T.unsafe(nil)); end
|
|
918
|
+
end
|
|
919
|
+
|
|
920
|
+
# pkg:gem/async#lib/async/notification.rb:23
|
|
921
|
+
class Async::Notification::Signal < ::Struct
|
|
922
|
+
# pkg:gem/async#lib/async/notification.rb:24
|
|
923
|
+
def alive?; end
|
|
924
|
+
|
|
925
|
+
# pkg:gem/async#lib/async/notification.rb:23
|
|
926
|
+
def ready; end
|
|
927
|
+
|
|
928
|
+
# pkg:gem/async#lib/async/notification.rb:23
|
|
929
|
+
def ready=(_); end
|
|
930
|
+
|
|
931
|
+
# pkg:gem/async#lib/async/notification.rb:28
|
|
932
|
+
def transfer; end
|
|
933
|
+
|
|
934
|
+
# pkg:gem/async#lib/async/notification.rb:23
|
|
935
|
+
def value; end
|
|
936
|
+
|
|
937
|
+
# pkg:gem/async#lib/async/notification.rb:23
|
|
938
|
+
def value=(_); end
|
|
939
|
+
|
|
940
|
+
class << self
|
|
941
|
+
# pkg:gem/async#lib/async/notification.rb:23
|
|
942
|
+
def [](*_arg0); end
|
|
943
|
+
|
|
944
|
+
# pkg:gem/async#lib/async/notification.rb:23
|
|
945
|
+
def inspect; end
|
|
946
|
+
|
|
947
|
+
# pkg:gem/async#lib/async/notification.rb:23
|
|
948
|
+
def keyword_init?; end
|
|
949
|
+
|
|
950
|
+
# pkg:gem/async#lib/async/notification.rb:23
|
|
951
|
+
def members; end
|
|
952
|
+
|
|
953
|
+
# pkg:gem/async#lib/async/notification.rb:23
|
|
954
|
+
def new(*_arg0); end
|
|
955
|
+
end
|
|
956
|
+
end
|
|
957
|
+
|
|
958
|
+
# Fiber::Profiler is not available.
|
|
959
|
+
#
|
|
960
|
+
# pkg:gem/async#lib/async/scheduler.rb:26
|
|
961
|
+
Async::Profiler = T.let(T.unsafe(nil), T.untyped)
|
|
962
|
+
|
|
963
|
+
# A promise represents a value that will be available in the future.
|
|
964
|
+
# Unlike Condition, once resolved (or rejected), all future waits return immediately
|
|
965
|
+
# with the stored value or raise the stored exception.
|
|
966
|
+
#
|
|
967
|
+
# This is thread-safe and integrates with the fiber scheduler.
|
|
968
|
+
#
|
|
969
|
+
# @public Since *Async v2*.
|
|
970
|
+
#
|
|
971
|
+
# pkg:gem/async#lib/async/promise.rb:20
|
|
972
|
+
class Async::Promise
|
|
973
|
+
# Create a new promise.
|
|
974
|
+
#
|
|
975
|
+
# pkg:gem/async#lib/async/promise.rb:22
|
|
976
|
+
def initialize; end
|
|
977
|
+
|
|
978
|
+
# Cancel the promise, indicating cancellation.
|
|
979
|
+
# All current and future waiters will receive nil.
|
|
980
|
+
# Can only be called on pending promises - no-op if already resolved.
|
|
981
|
+
#
|
|
982
|
+
# pkg:gem/async#lib/async/promise.rb:214
|
|
983
|
+
def cancel(exception = T.unsafe(nil)); end
|
|
984
|
+
|
|
985
|
+
# @returns [Boolean] Whether the promise has been cancelled.
|
|
986
|
+
#
|
|
987
|
+
# pkg:gem/async#lib/async/promise.rb:48
|
|
988
|
+
def cancelled?; end
|
|
989
|
+
|
|
990
|
+
# @returns [Boolean] Whether the promise has completed successfully.
|
|
991
|
+
#
|
|
992
|
+
# pkg:gem/async#lib/async/promise.rb:58
|
|
993
|
+
def completed?; end
|
|
994
|
+
|
|
995
|
+
# @returns [Boolean] Whether the promise failed with an exception.
|
|
996
|
+
#
|
|
997
|
+
# pkg:gem/async#lib/async/promise.rb:53
|
|
998
|
+
def failed?; end
|
|
999
|
+
|
|
1000
|
+
# Resolve the promise with the result of the block.
|
|
1001
|
+
# If the block raises an exception, the promise will be rejected.
|
|
1002
|
+
# If the promise was already resolved, the block will not be called.
|
|
1003
|
+
# @yields {...} The block to call to resolve the promise.
|
|
1004
|
+
# @returns [Object] The result of the block.
|
|
1005
|
+
#
|
|
1006
|
+
# pkg:gem/async#lib/async/promise.rb:234
|
|
1007
|
+
def fulfill(&block); end
|
|
1008
|
+
|
|
1009
|
+
# Reject the promise with an exception.
|
|
1010
|
+
# All current and future waiters will receive this exception.
|
|
1011
|
+
# Can only be called once - subsequent calls are ignored.
|
|
1012
|
+
#
|
|
1013
|
+
# @parameter exception [Exception] The exception to reject the promise with.
|
|
1014
|
+
#
|
|
1015
|
+
# pkg:gem/async#lib/async/promise.rb:197
|
|
1016
|
+
def reject(exception); end
|
|
1017
|
+
|
|
1018
|
+
# Resolve the promise with a value.
|
|
1019
|
+
# All current and future waiters will receive this value.
|
|
1020
|
+
# Can only be called once - subsequent calls are ignored.
|
|
1021
|
+
#
|
|
1022
|
+
# @parameter value [Object] The value to resolve the promise with.
|
|
1023
|
+
#
|
|
1024
|
+
# pkg:gem/async#lib/async/promise.rb:178
|
|
1025
|
+
def resolve(value); end
|
|
1026
|
+
|
|
1027
|
+
# @returns [Symbol | Nil] The internal resolved state (:completed, :failed, :cancelled, or nil if pending).
|
|
1028
|
+
# @private For internal use by Task.
|
|
1029
|
+
#
|
|
1030
|
+
# pkg:gem/async#lib/async/promise.rb:43
|
|
1031
|
+
def resolved; end
|
|
1032
|
+
|
|
1033
|
+
# @returns [Boolean] Whether the promise has been resolved or rejected.
|
|
1034
|
+
#
|
|
1035
|
+
# pkg:gem/async#lib/async/promise.rb:37
|
|
1036
|
+
def resolved?; end
|
|
1037
|
+
|
|
1038
|
+
# Artificially mark that someone is waiting (useful for suppressing warnings).
|
|
1039
|
+
# @private Internal use only.
|
|
1040
|
+
#
|
|
1041
|
+
# pkg:gem/async#lib/async/promise.rb:69
|
|
1042
|
+
def suppress_warnings!; end
|
|
1043
|
+
|
|
1044
|
+
# Non-blocking access to the current value. Returns nil if not yet resolved.
|
|
1045
|
+
# Does not raise exceptions even if the promise was rejected or cancelled.
|
|
1046
|
+
# For resolved promises, returns the raw stored value (result, exception, or cancel exception).
|
|
1047
|
+
#
|
|
1048
|
+
# @returns [Object | Nil] The stored value, or nil if pending.
|
|
1049
|
+
#
|
|
1050
|
+
# pkg:gem/async#lib/async/promise.rb:78
|
|
1051
|
+
def value; end
|
|
1052
|
+
|
|
1053
|
+
# Wait for the promise to be resolved and return the value.
|
|
1054
|
+
#
|
|
1055
|
+
# If already resolved, returns immediately. If rejected, raises the stored exception.
|
|
1056
|
+
#
|
|
1057
|
+
# @returns [Object] The resolved value.
|
|
1058
|
+
# @raises [Exception] The rejected or cancelled exception.
|
|
1059
|
+
# @raises [Async::TimeoutError] If timeout expires before the promise is resolved.
|
|
1060
|
+
#
|
|
1061
|
+
# pkg:gem/async#lib/async/promise.rb:160
|
|
1062
|
+
def wait(*, **, &); end
|
|
1063
|
+
|
|
1064
|
+
# Wait for the promise to be resolved (without raising exceptions).
|
|
1065
|
+
#
|
|
1066
|
+
# If already resolved, returns immediately. Otherwise, waits until resolution or timeout.
|
|
1067
|
+
#
|
|
1068
|
+
# @parameter timeout [Numeric | Nil] Maximum time to wait. If nil, waits indefinitely. If 0, returns immediately if not resolved.
|
|
1069
|
+
# @returns [Boolean] True if the promise is resolved, false if timeout expires
|
|
1070
|
+
#
|
|
1071
|
+
# pkg:gem/async#lib/async/promise.rb:125
|
|
1072
|
+
def wait?(timeout: T.unsafe(nil)); end
|
|
1073
|
+
|
|
1074
|
+
# @returns [Boolean] Whether any fibers are currently waiting for this promise.
|
|
1075
|
+
#
|
|
1076
|
+
# pkg:gem/async#lib/async/promise.rb:63
|
|
1077
|
+
def waiting?; end
|
|
1078
|
+
|
|
1079
|
+
private
|
|
1080
|
+
|
|
1081
|
+
# Wait indefinitely for the promise to be resolved.
|
|
1082
|
+
#
|
|
1083
|
+
# pkg:gem/async#lib/async/promise.rb:83
|
|
1084
|
+
def wait_indefinitely; end
|
|
1085
|
+
|
|
1086
|
+
# Wait for the promise to be resolved, respecting the deadline timeout.
|
|
1087
|
+
# @parameter timeout [Numeric] The timeout duration.
|
|
1088
|
+
# @returns [Boolean] True if resolved, false if timeout expires.
|
|
1089
|
+
#
|
|
1090
|
+
# pkg:gem/async#lib/async/promise.rb:92
|
|
1091
|
+
def wait_with_timeout(timeout); end
|
|
1092
|
+
|
|
1093
|
+
class << self
|
|
1094
|
+
# If a promise is given, fulfill it with the result of the block.
|
|
1095
|
+
# If no promise is given, simply yield to the block.
|
|
1096
|
+
# This is useful for methods that may optionally take a promise to fulfill.
|
|
1097
|
+
# @parameter promise [Promise | Nil] The optional promise to fulfill.
|
|
1098
|
+
# @yields {...} The block to call to resolve the promise or return a value.
|
|
1099
|
+
# @returns [Object] The result of the block.
|
|
1100
|
+
#
|
|
1101
|
+
# pkg:gem/async#lib/async/promise.rb:258
|
|
1102
|
+
def fulfill(promise, &block); end
|
|
1103
|
+
end
|
|
1104
|
+
end
|
|
1105
|
+
|
|
1106
|
+
# A thread-safe queue which allows items to be processed in order.
|
|
1107
|
+
#
|
|
1108
|
+
# This implementation uses Thread::Queue internally for thread safety while
|
|
1109
|
+
# maintaining compatibility with the fiber scheduler.
|
|
1110
|
+
#
|
|
1111
|
+
# It has a compatible interface with {Notification} and {Condition}, except that it's multi-value.
|
|
1112
|
+
#
|
|
1113
|
+
# @asynchronous This class is thread-safe.
|
|
1114
|
+
# @public Since *Async v1*.
|
|
1115
|
+
#
|
|
1116
|
+
# pkg:gem/async#lib/async/queue.rb:22
|
|
1117
|
+
class Async::Queue
|
|
1118
|
+
# Create a new thread-safe queue.
|
|
1119
|
+
#
|
|
1120
|
+
# @parameter parent [Interface(:async) | Nil] The parent task to use for async operations.
|
|
1121
|
+
#
|
|
1122
|
+
# pkg:gem/async#lib/async/queue.rb:31
|
|
1123
|
+
def initialize(parent: T.unsafe(nil), delegate: T.unsafe(nil)); end
|
|
1124
|
+
|
|
1125
|
+
# Compatibility with {::Queue#push}.
|
|
1126
|
+
#
|
|
1127
|
+
# pkg:gem/async#lib/async/queue.rb:69
|
|
1128
|
+
def <<(item); end
|
|
1129
|
+
|
|
1130
|
+
# Process each item in the queue.
|
|
1131
|
+
#
|
|
1132
|
+
# @asynchronous Executes the given block concurrently for each item.
|
|
1133
|
+
#
|
|
1134
|
+
# @parameter arguments [Array] The arguments to pass to the block.
|
|
1135
|
+
# @parameter parent [Interface(:async) | Nil] The parent task to use for async operations.
|
|
1136
|
+
# @parameter options [Hash] The options to pass to the task.
|
|
1137
|
+
# @yields {|task| ...} When the system is idle, the block will be executed in a new task.
|
|
1138
|
+
#
|
|
1139
|
+
# pkg:gem/async#lib/async/queue.rb:102
|
|
1140
|
+
def async(parent: T.unsafe(nil), **options, &block); end
|
|
1141
|
+
|
|
1142
|
+
# Close the queue, causing all waiting tasks to return `nil`. Any subsequent calls to {enqueue} will raise an exception.
|
|
1143
|
+
#
|
|
1144
|
+
# pkg:gem/async#lib/async/queue.rb:42
|
|
1145
|
+
def close; end
|
|
1146
|
+
|
|
1147
|
+
# @returns [Boolean] Whether the queue is closed.
|
|
1148
|
+
#
|
|
1149
|
+
# pkg:gem/async#lib/async/queue.rb:37
|
|
1150
|
+
def closed?; end
|
|
1151
|
+
|
|
1152
|
+
# Remove and return the next item from the queue.
|
|
1153
|
+
# @parameter timeout [Numeric, nil] Maximum time to wait for an item. If nil, waits indefinitely. If 0, returns immediately.
|
|
1154
|
+
# @returns [Object, nil] The dequeued item, or nil if timeout expires.
|
|
1155
|
+
#
|
|
1156
|
+
# pkg:gem/async#lib/async/queue.rb:83
|
|
1157
|
+
def dequeue(timeout: T.unsafe(nil)); end
|
|
1158
|
+
|
|
1159
|
+
# Enumerate each item in the queue.
|
|
1160
|
+
#
|
|
1161
|
+
# pkg:gem/async#lib/async/queue.rb:109
|
|
1162
|
+
def each; end
|
|
1163
|
+
|
|
1164
|
+
# @returns [Boolean] Whether the queue is empty.
|
|
1165
|
+
#
|
|
1166
|
+
# pkg:gem/async#lib/async/queue.rb:52
|
|
1167
|
+
def empty?; end
|
|
1168
|
+
|
|
1169
|
+
# Add multiple items to the queue.
|
|
1170
|
+
#
|
|
1171
|
+
# pkg:gem/async#lib/async/queue.rb:74
|
|
1172
|
+
def enqueue(*items); end
|
|
1173
|
+
|
|
1174
|
+
# Compatibility with {::Queue#pop}.
|
|
1175
|
+
# @parameter timeout [Numeric, nil] Maximum time to wait for an item. If nil, waits indefinitely. If 0, returns immediately.
|
|
1176
|
+
# @returns [Object, nil] The dequeued item, or nil if timeout expires.
|
|
1177
|
+
#
|
|
1178
|
+
# pkg:gem/async#lib/async/queue.rb:90
|
|
1179
|
+
def pop(timeout: T.unsafe(nil)); end
|
|
1180
|
+
|
|
1181
|
+
# Add an item to the queue.
|
|
1182
|
+
#
|
|
1183
|
+
# pkg:gem/async#lib/async/queue.rb:62
|
|
1184
|
+
def push(item); end
|
|
1185
|
+
|
|
1186
|
+
# Signal the queue with a value, the same as {#enqueue}.
|
|
1187
|
+
#
|
|
1188
|
+
# pkg:gem/async#lib/async/queue.rb:116
|
|
1189
|
+
def signal(value = T.unsafe(nil)); end
|
|
1190
|
+
|
|
1191
|
+
# @returns [Integer] The number of items in the queue.
|
|
1192
|
+
#
|
|
1193
|
+
# pkg:gem/async#lib/async/queue.rb:47
|
|
1194
|
+
def size; end
|
|
1195
|
+
|
|
1196
|
+
# Wait for an item to be available, the same as {#dequeue}.
|
|
1197
|
+
#
|
|
1198
|
+
# pkg:gem/async#lib/async/queue.rb:121
|
|
1199
|
+
def wait; end
|
|
1200
|
+
|
|
1201
|
+
# @returns [Integer] The number of tasks waiting for an item.
|
|
1202
|
+
#
|
|
1203
|
+
# pkg:gem/async#lib/async/queue.rb:57
|
|
1204
|
+
def waiting_count; end
|
|
1205
|
+
end
|
|
1206
|
+
|
|
1207
|
+
# An error raised when trying to enqueue items to a closed queue.
|
|
1208
|
+
# @public Since *Async v2.24*.
|
|
1209
|
+
#
|
|
1210
|
+
# pkg:gem/async#lib/async/queue.rb:25
|
|
1211
|
+
class Async::Queue::ClosedError < ::RuntimeError; end
|
|
1212
|
+
|
|
1213
|
+
# A wrapper around the the scheduler which binds it to the current thread automatically.
|
|
1214
|
+
#
|
|
1215
|
+
# pkg:gem/async#lib/async/reactor.rb:12
|
|
1216
|
+
class Async::Reactor < ::Async::Scheduler
|
|
1217
|
+
# Initialize the reactor and assign it to the current Fiber scheduler.
|
|
1218
|
+
#
|
|
1219
|
+
# pkg:gem/async#lib/async/reactor.rb:21
|
|
1220
|
+
def initialize(*, **, &); end
|
|
1221
|
+
|
|
1222
|
+
# Close the reactor and remove it from the current Fiber scheduler.
|
|
1223
|
+
#
|
|
1224
|
+
# pkg:gem/async#lib/async/reactor.rb:28
|
|
1225
|
+
def scheduler_close; end
|
|
1226
|
+
|
|
1227
|
+
# pkg:gem/async#lib/async/reactor.rb:32
|
|
1228
|
+
def sleep(*_arg0); end
|
|
1229
|
+
|
|
1230
|
+
class << self
|
|
1231
|
+
# @deprecated Replaced by {Kernel::Async}.
|
|
1232
|
+
#
|
|
1233
|
+
# pkg:gem/async#lib/async/reactor.rb:14
|
|
1234
|
+
def run(*, **, &); end
|
|
1235
|
+
end
|
|
1236
|
+
end
|
|
1237
|
+
|
|
1238
|
+
# Handles scheduling of fibers. Implements the fiber scheduler interface.
|
|
1239
|
+
#
|
|
1240
|
+
# pkg:gem/async#lib/async/scheduler.rb:30
|
|
1241
|
+
class Async::Scheduler < ::Async::Node
|
|
1242
|
+
# Create a new scheduler.
|
|
1243
|
+
#
|
|
1244
|
+
# @public Since *Async v1*.
|
|
1245
|
+
# @parameter parent [Node | Nil] The parent node to use for task hierarchy.
|
|
1246
|
+
# @parameter selector [IO::Event::Selector] The selector to use for event handling.
|
|
1247
|
+
#
|
|
1248
|
+
# pkg:gem/async#lib/async/scheduler.rb:78
|
|
1249
|
+
def initialize(parent = T.unsafe(nil), selector: T.unsafe(nil), profiler: T.unsafe(nil), worker_pool: T.unsafe(nil)); end
|
|
1250
|
+
|
|
1251
|
+
# Resolve the address of the given hostname.
|
|
1252
|
+
#
|
|
1253
|
+
# @public Since *Async v2*.
|
|
1254
|
+
# @asynchronous May be non-blocking.
|
|
1255
|
+
#
|
|
1256
|
+
# @parameter hostname [String] The hostname to resolve.
|
|
1257
|
+
#
|
|
1258
|
+
# pkg:gem/async#lib/async/scheduler.rb:295
|
|
1259
|
+
def address_resolve(hostname); end
|
|
1260
|
+
|
|
1261
|
+
# Start an asynchronous task within the specified reactor. The task will be executed until the first blocking call, at which point it will yield and and this method will return.
|
|
1262
|
+
#
|
|
1263
|
+
# @public Since *Async v1*.
|
|
1264
|
+
# @asynchronous May context switch immediately to new task.
|
|
1265
|
+
# @deprecated Use {#run} or {Task#async} instead.
|
|
1266
|
+
#
|
|
1267
|
+
# @yields {|task| ...} Executed within the task.
|
|
1268
|
+
# @returns [Task] The task that was scheduled into the reactor.
|
|
1269
|
+
#
|
|
1270
|
+
# pkg:gem/async#lib/async/scheduler.rb:633
|
|
1271
|
+
def async(*arguments, **options, &block); end
|
|
1272
|
+
|
|
1273
|
+
# Invoked when a fiber tries to perform a blocking operation which cannot continue. A corresponding call {unblock} must be performed to allow this fiber to continue.
|
|
1274
|
+
#
|
|
1275
|
+
# @public Since *Async v2*.
|
|
1276
|
+
# @asynchronous May only be called on same thread as fiber scheduler.
|
|
1277
|
+
#
|
|
1278
|
+
# @parameter blocker [Object] The object that is blocking the fiber.
|
|
1279
|
+
# @parameter timeout [Float | Nil] The maximum time to block, or if nil, indefinitely.
|
|
1280
|
+
#
|
|
1281
|
+
# pkg:gem/async#lib/async/scheduler.rb:234
|
|
1282
|
+
def block(blocker, timeout); end
|
|
1283
|
+
|
|
1284
|
+
# Cancel all children, including transient children.
|
|
1285
|
+
#
|
|
1286
|
+
# @public Since *Async v1*.
|
|
1287
|
+
#
|
|
1288
|
+
# pkg:gem/async#lib/async/scheduler.rb:534
|
|
1289
|
+
def cancel(later = T.unsafe(nil), cause: T.unsafe(nil)); end
|
|
1290
|
+
|
|
1291
|
+
# Terminate all child tasks and close the scheduler.
|
|
1292
|
+
# @public Since *Async v1*.
|
|
1293
|
+
#
|
|
1294
|
+
# pkg:gem/async#lib/async/scheduler.rb:150
|
|
1295
|
+
def close; end
|
|
1296
|
+
|
|
1297
|
+
# @returns [Boolean] Whether the scheduler has been closed.
|
|
1298
|
+
# @public Since *Async v1*.
|
|
1299
|
+
#
|
|
1300
|
+
# pkg:gem/async#lib/async/scheduler.rb:177
|
|
1301
|
+
def closed?; end
|
|
1302
|
+
|
|
1303
|
+
# Create a new fiber and return it without starting execution.
|
|
1304
|
+
# @returns [Fiber] The fiber that was created.
|
|
1305
|
+
#
|
|
1306
|
+
# pkg:gem/async#lib/async/scheduler.rb:648
|
|
1307
|
+
def fiber(*, **, &); end
|
|
1308
|
+
|
|
1309
|
+
# Raise an exception on the specified fiber, waking up the event loop if necessary.
|
|
1310
|
+
#
|
|
1311
|
+
# pkg:gem/async#lib/async/scheduler.rb:412
|
|
1312
|
+
def fiber_interrupt(fiber, exception); end
|
|
1313
|
+
|
|
1314
|
+
# Interrupt the event loop and cause it to exit.
|
|
1315
|
+
# @asynchronous May be called from any thread.
|
|
1316
|
+
#
|
|
1317
|
+
# pkg:gem/async#lib/async/scheduler.rb:188
|
|
1318
|
+
def interrupt; end
|
|
1319
|
+
|
|
1320
|
+
# Read at most the specified number of bytes from the IO into the buffer.
|
|
1321
|
+
#
|
|
1322
|
+
# @public Since *Async v2* and Ruby with `IO::Buffer` support.
|
|
1323
|
+
# @asynchronous May be non-blocking.
|
|
1324
|
+
#
|
|
1325
|
+
# @parameter io [IO] The IO object to read from.
|
|
1326
|
+
# @parameter buffer [IO::Buffer] The buffer to read into.
|
|
1327
|
+
# @parameter offset [Integer] The offset within the buffer to read into.
|
|
1328
|
+
# @parameter length [Integer] The maximum number of bytes to read.
|
|
1329
|
+
#
|
|
1330
|
+
# pkg:gem/async#lib/async/scheduler.rb:349
|
|
1331
|
+
def io_read(io, buffer, offset, length); end
|
|
1332
|
+
|
|
1333
|
+
# Wait for the specified IOs to become ready for the specified events.
|
|
1334
|
+
#
|
|
1335
|
+
# @public Since *Async v2.25*.
|
|
1336
|
+
# @asynchronous May be non-blocking.
|
|
1337
|
+
#
|
|
1338
|
+
# pkg:gem/async#lib/async/scheduler.rb:441
|
|
1339
|
+
def io_select(*, **, &); end
|
|
1340
|
+
|
|
1341
|
+
# Wait for the specified IO to become ready for the specified events.
|
|
1342
|
+
#
|
|
1343
|
+
# @public Since *Async v2*.
|
|
1344
|
+
# @asynchronous May be non-blocking.
|
|
1345
|
+
#
|
|
1346
|
+
# @parameter io [IO] The IO object to wait on.
|
|
1347
|
+
# @parameter events [Integer] The events to wait for, e.g. `IO::READABLE`, `IO::WRITABLE`, etc.
|
|
1348
|
+
# @parameter timeout [Float | Nil] The maximum time to wait, or if nil, indefinitely.
|
|
1349
|
+
# @returns [Integer | false] The subset of events that are ready, or `false` if the timeout expires.
|
|
1350
|
+
#
|
|
1351
|
+
# pkg:gem/async#lib/async/scheduler.rb:311
|
|
1352
|
+
def io_wait(io, events, timeout = T.unsafe(nil)); end
|
|
1353
|
+
|
|
1354
|
+
# Write at most the specified number of bytes from the buffer to the IO.
|
|
1355
|
+
#
|
|
1356
|
+
# @public Since *Async v2* and *Ruby v3.3.1* with `IO::Buffer` support.
|
|
1357
|
+
# @asynchronous May be non-blocking.
|
|
1358
|
+
#
|
|
1359
|
+
# @parameter io [IO] The IO object to write to.
|
|
1360
|
+
# @parameter buffer [IO::Buffer] The buffer to write from.
|
|
1361
|
+
# @parameter offset [Integer] The offset within the buffer to write from.
|
|
1362
|
+
# @parameter length [Integer] The maximum number of bytes to write.
|
|
1363
|
+
#
|
|
1364
|
+
# pkg:gem/async#lib/async/scheduler.rb:373
|
|
1365
|
+
def io_write(io, buffer, offset, length); end
|
|
1366
|
+
|
|
1367
|
+
# Sleep for the specified duration.
|
|
1368
|
+
#
|
|
1369
|
+
# @public Since *Async v2* and *Ruby v3.1*.
|
|
1370
|
+
# @asynchronous May be non-blocking.
|
|
1371
|
+
#
|
|
1372
|
+
# @parameter duration [Numeric | Nil] The time in seconds to sleep, or if nil, indefinitely.
|
|
1373
|
+
#
|
|
1374
|
+
# pkg:gem/async#lib/async/scheduler.rb:279
|
|
1375
|
+
def kernel_sleep(duration = T.unsafe(nil)); end
|
|
1376
|
+
|
|
1377
|
+
# Compute the scheduler load according to the busy and idle times that are updated by the run loop.
|
|
1378
|
+
#
|
|
1379
|
+
# @returns [Float] The load of the scheduler. 0.0 means no load, 1.0 means fully loaded or over-loaded.
|
|
1380
|
+
#
|
|
1381
|
+
# pkg:gem/async#lib/async/scheduler.rb:107
|
|
1382
|
+
def load; end
|
|
1383
|
+
|
|
1384
|
+
# Handle fork in the child process. This method is called automatically when `Process.fork` is invoked on Ruby versions < 4 and cleans up the scheduler state. On Ruby 4+, the scheduler is automatically cleaned up by the Ruby runtime.
|
|
1385
|
+
#
|
|
1386
|
+
# The child process starts with a clean slate - no scheduler is set. Users can create a new scheduler if needed.
|
|
1387
|
+
#
|
|
1388
|
+
# @public Since *Async v2.35*.
|
|
1389
|
+
#
|
|
1390
|
+
# pkg:gem/async#lib/async/scheduler.rb:699
|
|
1391
|
+
def process_fork; end
|
|
1392
|
+
|
|
1393
|
+
# Wait for the specified process ID to exit.
|
|
1394
|
+
#
|
|
1395
|
+
# @public Since *Async v2*.
|
|
1396
|
+
# @asynchronous May be non-blocking.
|
|
1397
|
+
#
|
|
1398
|
+
# @parameter pid [Integer] The process ID to wait for.
|
|
1399
|
+
# @parameter flags [Integer] A bit-mask of flags suitable for `Process::Status.wait`.
|
|
1400
|
+
# @returns [Process::Status] A process status instance.
|
|
1401
|
+
# @asynchronous May be non-blocking..
|
|
1402
|
+
#
|
|
1403
|
+
# pkg:gem/async#lib/async/scheduler.rb:426
|
|
1404
|
+
def process_wait(pid, flags); end
|
|
1405
|
+
|
|
1406
|
+
# Schedule a fiber (or equivalent object) to be resumed on the next loop through the reactor.
|
|
1407
|
+
# @parameter fiber [Fiber | Object] The object to be resumed on the next iteration of the run-loop.
|
|
1408
|
+
#
|
|
1409
|
+
# pkg:gem/async#lib/async/scheduler.rb:205
|
|
1410
|
+
def push(fiber); end
|
|
1411
|
+
|
|
1412
|
+
# Raise an exception on a specified fiber with the given arguments.
|
|
1413
|
+
#
|
|
1414
|
+
# This internally schedules the current fiber to be ready, before raising the exception, so that it will later resume execution.
|
|
1415
|
+
#
|
|
1416
|
+
# @parameter fiber [Fiber] The fiber to raise the exception on.
|
|
1417
|
+
# @parameter *arguments [Array] The arguments to pass to the fiber.
|
|
1418
|
+
#
|
|
1419
|
+
# pkg:gem/async#lib/async/scheduler.rb:215
|
|
1420
|
+
def raise(*, **, &); end
|
|
1421
|
+
|
|
1422
|
+
# Resume execution of the specified fiber.
|
|
1423
|
+
#
|
|
1424
|
+
# @parameter fiber [Fiber] The fiber to resume.
|
|
1425
|
+
# @parameter arguments [Array] The arguments to pass to the fiber.
|
|
1426
|
+
#
|
|
1427
|
+
# pkg:gem/async#lib/async/scheduler.rb:223
|
|
1428
|
+
def resume(fiber, *arguments); end
|
|
1429
|
+
|
|
1430
|
+
# Run the reactor until all tasks are finished. Proxies arguments to {#async} immediately before entering the loop, if a block is provided.
|
|
1431
|
+
#
|
|
1432
|
+
# Forwards all parameters to {#async} if a block is given.
|
|
1433
|
+
#
|
|
1434
|
+
# @public Since *Async v1*.
|
|
1435
|
+
#
|
|
1436
|
+
# @yields {|task| ...} The top level task, if a block is given.
|
|
1437
|
+
# @returns [Task] The initial task that was scheduled into the reactor.
|
|
1438
|
+
#
|
|
1439
|
+
# pkg:gem/async#lib/async/scheduler.rb:601
|
|
1440
|
+
def run(*, **, &); end
|
|
1441
|
+
|
|
1442
|
+
# Run one iteration of the event loop.
|
|
1443
|
+
#
|
|
1444
|
+
# @public Since *Async v1*.
|
|
1445
|
+
# @asynchronous Must be invoked from blocking (root) fiber.
|
|
1446
|
+
#
|
|
1447
|
+
# @parameter timeout [Float | Nil] The maximum timeout, or if nil, indefinite.
|
|
1448
|
+
# @returns [Boolean] Whether there is more work to do.
|
|
1449
|
+
#
|
|
1450
|
+
# pkg:gem/async#lib/async/scheduler.rb:500
|
|
1451
|
+
def run_once(timeout = T.unsafe(nil)); end
|
|
1452
|
+
|
|
1453
|
+
# Invoked when the fiber scheduler is being closed.
|
|
1454
|
+
#
|
|
1455
|
+
# Executes the run loop until all tasks are finished, then closes the scheduler.
|
|
1456
|
+
#
|
|
1457
|
+
# pkg:gem/async#lib/async/scheduler.rb:129
|
|
1458
|
+
def scheduler_close(error = T.unsafe(nil)); end
|
|
1459
|
+
|
|
1460
|
+
# Backward compatibility alias for cancel.
|
|
1461
|
+
#
|
|
1462
|
+
# pkg:gem/async#lib/async/scheduler.rb:545
|
|
1463
|
+
def stop(*, **, &); end
|
|
1464
|
+
|
|
1465
|
+
# Terminate all child tasks.
|
|
1466
|
+
#
|
|
1467
|
+
# pkg:gem/async#lib/async/scheduler.rb:139
|
|
1468
|
+
def terminate; end
|
|
1469
|
+
|
|
1470
|
+
# Invoke the block, but after the specified timeout, raise the specified exception with the given message. If the block runs to completion before the timeout occurs or there are no non-blocking operations after the timeout expires, the code will complete without any exception.
|
|
1471
|
+
#
|
|
1472
|
+
# @public Since *Async v1* and *Ruby v3.1*. May be invoked from `Timeout.timeout`.
|
|
1473
|
+
# @asynchronous May raise an exception at any interruption point (e.g. blocking operations).
|
|
1474
|
+
#
|
|
1475
|
+
# @parameter duration [Numeric] The time in seconds, in which the task should complete.
|
|
1476
|
+
# @parameter exception [Class] The exception class to raise.
|
|
1477
|
+
# @parameter message [String] The message to pass to the exception.
|
|
1478
|
+
# @yields {|duration| ...} The block to execute with a timeout.
|
|
1479
|
+
#
|
|
1480
|
+
# pkg:gem/async#lib/async/scheduler.rb:688
|
|
1481
|
+
def timeout_after(duration, exception, message, &block); end
|
|
1482
|
+
|
|
1483
|
+
# @returns [String] A description of the scheduler.
|
|
1484
|
+
#
|
|
1485
|
+
# pkg:gem/async#lib/async/scheduler.rb:182
|
|
1486
|
+
def to_s; end
|
|
1487
|
+
|
|
1488
|
+
# Transfer from the calling fiber to the event loop.
|
|
1489
|
+
#
|
|
1490
|
+
# pkg:gem/async#lib/async/scheduler.rb:194
|
|
1491
|
+
def transfer; end
|
|
1492
|
+
|
|
1493
|
+
# Unblock a fiber that was previously blocked.
|
|
1494
|
+
#
|
|
1495
|
+
# @public Since *Async v2* and *Ruby v3.1*.
|
|
1496
|
+
# @asynchronous May be called from any thread.
|
|
1497
|
+
#
|
|
1498
|
+
# @parameter blocker [Object] The object that was blocking the fiber.
|
|
1499
|
+
# @parameter fiber [Fiber] The fiber to unblock.
|
|
1500
|
+
#
|
|
1501
|
+
# pkg:gem/async#lib/async/scheduler.rb:263
|
|
1502
|
+
def unblock(blocker, fiber); end
|
|
1503
|
+
|
|
1504
|
+
# Invoke the block, but after the specified timeout, raise {TimeoutError} in any currenly blocking operation. If the block runs to completion before the timeout occurs or there are no non-blocking operations after the timeout expires, the code will complete without any exception.
|
|
1505
|
+
#
|
|
1506
|
+
# @public Since *Async v1*.
|
|
1507
|
+
# @asynchronous May raise an exception at any interruption point (e.g. blocking operations).
|
|
1508
|
+
#
|
|
1509
|
+
# @parameter duration [Numeric] The time in seconds, in which the task should complete.
|
|
1510
|
+
# @parameter exception [Class] The exception class to raise.
|
|
1511
|
+
# @parameter message [String] The message to pass to the exception.
|
|
1512
|
+
# @yields {|timeout| ...} The block to execute with a timeout.
|
|
1513
|
+
#
|
|
1514
|
+
# pkg:gem/async#lib/async/scheduler.rb:661
|
|
1515
|
+
def with_timeout(duration, exception = T.unsafe(nil), message = T.unsafe(nil), &block); end
|
|
1516
|
+
|
|
1517
|
+
# Yield the current fiber and resume it on the next iteration of the event loop.
|
|
1518
|
+
#
|
|
1519
|
+
# pkg:gem/async#lib/async/scheduler.rb:199
|
|
1520
|
+
def yield; end
|
|
1521
|
+
|
|
1522
|
+
private
|
|
1523
|
+
|
|
1524
|
+
# Checks and clears the interrupted state of the scheduler.
|
|
1525
|
+
#
|
|
1526
|
+
# @returns [Boolean] Whether the reactor has been interrupted.
|
|
1527
|
+
#
|
|
1528
|
+
# pkg:gem/async#lib/async/scheduler.rb:518
|
|
1529
|
+
def interrupted?; end
|
|
1530
|
+
|
|
1531
|
+
# Run the event loop, until the scheduler is interrupted or finished.
|
|
1532
|
+
#
|
|
1533
|
+
# @parameter initial [Proc | Nil] The initial block to execute before the first loop iteration.
|
|
1534
|
+
# @yields {...} The block to execute on each loop iteration.
|
|
1535
|
+
# @raises {Interrupt} If the scheduler is interrupted.
|
|
1536
|
+
#
|
|
1537
|
+
# pkg:gem/async#lib/async/scheduler.rb:554
|
|
1538
|
+
def run_loop(initial = T.unsafe(nil), &block); end
|
|
1539
|
+
|
|
1540
|
+
# Run one iteration of the event loop.
|
|
1541
|
+
#
|
|
1542
|
+
# When terminating the event loop, we already know we are finished. So we don't need to check the task tree. This is a logical requirement because `run_once` ignores transient tasks. For example, a single top level transient task is not enough to keep the reactor running, but during termination we must still process it in order to terminate child tasks.
|
|
1543
|
+
#
|
|
1544
|
+
# @parameter timeout [Float | Nil] The maximum timeout, or if nil, indefinite.
|
|
1545
|
+
# @returns [Boolean] Whether there is more work to do.
|
|
1546
|
+
#
|
|
1547
|
+
# pkg:gem/async#lib/async/scheduler.rb:456
|
|
1548
|
+
def run_once!(timeout = T.unsafe(nil)); end
|
|
1549
|
+
|
|
1550
|
+
class << self
|
|
1551
|
+
# Whether the fiber scheduler is supported.
|
|
1552
|
+
# @public Since *Async v1*.
|
|
1553
|
+
#
|
|
1554
|
+
# pkg:gem/async#lib/async/scheduler.rb:47
|
|
1555
|
+
def supported?; end
|
|
1556
|
+
end
|
|
1557
|
+
end
|
|
1558
|
+
|
|
1559
|
+
# Used to augment the scheduler to add support for blocking operations.
|
|
1560
|
+
#
|
|
1561
|
+
# pkg:gem/async#lib/async/scheduler.rb:52
|
|
1562
|
+
module Async::Scheduler::BlockingOperationWait
|
|
1563
|
+
# Wait for the given work to be executed.
|
|
1564
|
+
#
|
|
1565
|
+
# @public Since *Async v2.21* and *Ruby v3.4*.
|
|
1566
|
+
# @asynchronous May be non-blocking.
|
|
1567
|
+
#
|
|
1568
|
+
# @parameter work [Proc] The work to execute on a background thread.
|
|
1569
|
+
# @returns [Object] The result of the work.
|
|
1570
|
+
#
|
|
1571
|
+
# pkg:gem/async#lib/async/scheduler.rb:60
|
|
1572
|
+
def blocking_operation_wait(work); end
|
|
1573
|
+
end
|
|
1574
|
+
|
|
1575
|
+
# Raised when an operation is attempted on a closed scheduler.
|
|
1576
|
+
#
|
|
1577
|
+
# pkg:gem/async#lib/async/scheduler.rb:36
|
|
1578
|
+
class Async::Scheduler::ClosedError < ::RuntimeError
|
|
1579
|
+
# Create a new error.
|
|
1580
|
+
#
|
|
1581
|
+
# @parameter message [String] The error message.
|
|
1582
|
+
#
|
|
1583
|
+
# pkg:gem/async#lib/async/scheduler.rb:40
|
|
1584
|
+
def initialize(message = T.unsafe(nil)); end
|
|
1585
|
+
end
|
|
1586
|
+
|
|
1587
|
+
# Used to defer stopping the current task until later.
|
|
1588
|
+
#
|
|
1589
|
+
# pkg:gem/async#lib/async/scheduler.rb:390
|
|
1590
|
+
class Async::Scheduler::FiberInterrupt
|
|
1591
|
+
# Create a new stop later operation.
|
|
1592
|
+
#
|
|
1593
|
+
# @parameter task [Task] The task to stop later.
|
|
1594
|
+
#
|
|
1595
|
+
# pkg:gem/async#lib/async/scheduler.rb:394
|
|
1596
|
+
def initialize(fiber, exception); end
|
|
1597
|
+
|
|
1598
|
+
# @returns [Boolean] Whether the task is alive.
|
|
1599
|
+
#
|
|
1600
|
+
# pkg:gem/async#lib/async/scheduler.rb:400
|
|
1601
|
+
def alive?; end
|
|
1602
|
+
|
|
1603
|
+
# Transfer control to the operation - this will stop the task.
|
|
1604
|
+
#
|
|
1605
|
+
# pkg:gem/async#lib/async/scheduler.rb:405
|
|
1606
|
+
def transfer; end
|
|
1607
|
+
end
|
|
1608
|
+
|
|
1609
|
+
# pkg:gem/async#lib/async/scheduler.rb:31
|
|
1610
|
+
Async::Scheduler::WORKER_POOL = T.let(T.unsafe(nil), T.untyped)
|
|
1611
|
+
|
|
1612
|
+
# pkg:gem/async#lib/async/scheduler.rb:70
|
|
1613
|
+
Async::Scheduler::WorkerPool = T.let(T.unsafe(nil), T.untyped)
|
|
1614
|
+
|
|
1615
|
+
# A synchronization primitive, which limits access to a given resource.
|
|
1616
|
+
# @public Since *Async v1*.
|
|
1617
|
+
#
|
|
1618
|
+
# pkg:gem/async#lib/async/semaphore.rb:11
|
|
1619
|
+
class Async::Semaphore
|
|
1620
|
+
# @parameter limit [Integer] The maximum number of times the semaphore can be acquired before it blocks.
|
|
1621
|
+
# @parameter parent [Task | Semaphore | Nil] The parent for holding any children tasks.
|
|
1622
|
+
#
|
|
1623
|
+
# pkg:gem/async#lib/async/semaphore.rb:14
|
|
1624
|
+
def initialize(limit = T.unsafe(nil), parent: T.unsafe(nil)); end
|
|
1625
|
+
|
|
1626
|
+
# Acquire the semaphore, block if we are at the limit.
|
|
1627
|
+
# If no block is provided, you must call release manually.
|
|
1628
|
+
# @yields {...} When the semaphore can be acquired.
|
|
1629
|
+
# @returns The result of the block if invoked.
|
|
1630
|
+
#
|
|
1631
|
+
# pkg:gem/async#lib/async/semaphore.rb:79
|
|
1632
|
+
def acquire; end
|
|
1633
|
+
|
|
1634
|
+
# Run an async task. Will wait until the semaphore is ready until spawning and running the task.
|
|
1635
|
+
#
|
|
1636
|
+
# pkg:gem/async#lib/async/semaphore.rb:61
|
|
1637
|
+
def async(*arguments, parent: T.unsafe(nil), **options); end
|
|
1638
|
+
|
|
1639
|
+
# Whether trying to acquire this semaphore would block.
|
|
1640
|
+
#
|
|
1641
|
+
# pkg:gem/async#lib/async/semaphore.rb:56
|
|
1642
|
+
def blocking?; end
|
|
1643
|
+
|
|
1644
|
+
# The current number of tasks that have acquired the semaphore.
|
|
1645
|
+
#
|
|
1646
|
+
# pkg:gem/async#lib/async/semaphore.rb:23
|
|
1647
|
+
def count; end
|
|
1648
|
+
|
|
1649
|
+
# Is the semaphore currently acquired?
|
|
1650
|
+
#
|
|
1651
|
+
# pkg:gem/async#lib/async/semaphore.rb:51
|
|
1652
|
+
def empty?; end
|
|
1653
|
+
|
|
1654
|
+
# The maximum number of tasks that can acquire the semaphore.
|
|
1655
|
+
#
|
|
1656
|
+
# pkg:gem/async#lib/async/semaphore.rb:26
|
|
1657
|
+
def limit; end
|
|
1658
|
+
|
|
1659
|
+
# Allow setting the limit. This is useful for cases where the semaphore is used to limit the number of concurrent tasks, but the number of tasks is not known in advance or needs to be modified.
|
|
1660
|
+
#
|
|
1661
|
+
# On increasing the limit, some tasks may be immediately resumed. On decreasing the limit, some tasks may execute until the count is < than the limit.
|
|
1662
|
+
#
|
|
1663
|
+
# @parameter limit [Integer] The new limit.
|
|
1664
|
+
#
|
|
1665
|
+
# pkg:gem/async#lib/async/semaphore.rb:36
|
|
1666
|
+
def limit=(limit); end
|
|
1667
|
+
|
|
1668
|
+
# Release the semaphore. Must match up with a corresponding call to `acquire`. Will release waiting fibers in FIFO order.
|
|
1669
|
+
#
|
|
1670
|
+
# pkg:gem/async#lib/async/semaphore.rb:94
|
|
1671
|
+
def release; end
|
|
1672
|
+
|
|
1673
|
+
# The tasks waiting on this semaphore.
|
|
1674
|
+
#
|
|
1675
|
+
# pkg:gem/async#lib/async/semaphore.rb:29
|
|
1676
|
+
def waiting; end
|
|
1677
|
+
|
|
1678
|
+
private
|
|
1679
|
+
|
|
1680
|
+
# Wait until the semaphore becomes available.
|
|
1681
|
+
#
|
|
1682
|
+
# pkg:gem/async#lib/async/semaphore.rb:119
|
|
1683
|
+
def wait; end
|
|
1684
|
+
end
|
|
1685
|
+
|
|
1686
|
+
# pkg:gem/async#lib/async/semaphore.rb:104
|
|
1687
|
+
class Async::Semaphore::FiberNode < ::Async::List::Node
|
|
1688
|
+
# pkg:gem/async#lib/async/semaphore.rb:105
|
|
1689
|
+
def initialize(fiber); end
|
|
1690
|
+
|
|
1691
|
+
# pkg:gem/async#lib/async/semaphore.rb:109
|
|
1692
|
+
def resume; end
|
|
1693
|
+
end
|
|
1694
|
+
|
|
1695
|
+
# pkg:gem/async#lib/async/stop.rb:9
|
|
1696
|
+
Async::Stop = Async::Cancel
|
|
1697
|
+
|
|
1698
|
+
# Represents a sequential unit of work, defined by a block, which is executed concurrently with other tasks. A task can be in one of the following states: `initialized`, `running`, `completed`, `failed`, or `cancelled`.
|
|
1699
|
+
#
|
|
1700
|
+
# ```mermaid
|
|
1701
|
+
# stateDiagram-v2
|
|
1702
|
+
# [*] --> Initialized
|
|
1703
|
+
# Initialized --> Running : Run
|
|
1704
|
+
#
|
|
1705
|
+
# Running --> Completed : Return Value
|
|
1706
|
+
# Running --> Failed : Exception
|
|
1707
|
+
#
|
|
1708
|
+
# Completed --> [*]
|
|
1709
|
+
# Failed --> [*]
|
|
1710
|
+
#
|
|
1711
|
+
# Running --> Cancelled : Cancel
|
|
1712
|
+
# Cancelled --> [*]
|
|
1713
|
+
# Completed --> Cancelled : Cancel
|
|
1714
|
+
# Failed --> Cancelled : Cancel
|
|
1715
|
+
# Initialized --> Cancelled : Cancel
|
|
1716
|
+
# ```
|
|
1717
|
+
#
|
|
1718
|
+
# @example Creating a task that sleeps for 1 second.
|
|
1719
|
+
# require "async"
|
|
1720
|
+
# Async do |task|
|
|
1721
|
+
# sleep(1)
|
|
1722
|
+
# end
|
|
1723
|
+
#
|
|
1724
|
+
# @public Since *Async v1*.
|
|
1725
|
+
#
|
|
1726
|
+
# pkg:gem/async#lib/async/task.rb:52
|
|
1727
|
+
class Async::Task < ::Async::Node
|
|
1728
|
+
# Create a new task.
|
|
1729
|
+
# @parameter reactor [Reactor] the reactor this task will run within.
|
|
1730
|
+
# @parameter parent [Task] the parent task.
|
|
1731
|
+
#
|
|
1732
|
+
# pkg:gem/async#lib/async/task.rb:80
|
|
1733
|
+
def initialize(parent = T.unsafe(nil), finished: T.unsafe(nil), **options, &block); end
|
|
1734
|
+
|
|
1735
|
+
# @returns [Boolean] Whether the internal fiber is alive, i.e. it is actively executing.
|
|
1736
|
+
#
|
|
1737
|
+
# pkg:gem/async#lib/async/task.rb:166
|
|
1738
|
+
def alive?; end
|
|
1739
|
+
|
|
1740
|
+
# Annotate the task with a description.
|
|
1741
|
+
#
|
|
1742
|
+
# This will internally try to annotate the fiber if it is running, otherwise it will annotate the task itself.
|
|
1743
|
+
#
|
|
1744
|
+
# @parameter annotation [String] The description to annotate the task with.
|
|
1745
|
+
#
|
|
1746
|
+
# pkg:gem/async#lib/async/task.rb:123
|
|
1747
|
+
def annotate(annotation, &block); end
|
|
1748
|
+
|
|
1749
|
+
# @returns [Object] The annotation of the task.
|
|
1750
|
+
#
|
|
1751
|
+
# pkg:gem/async#lib/async/task.rb:132
|
|
1752
|
+
def annotation; end
|
|
1753
|
+
|
|
1754
|
+
# Run an asynchronous task as a child of the current task.
|
|
1755
|
+
#
|
|
1756
|
+
# @public Since *Async v1*.
|
|
1757
|
+
# @asynchronous May context switch immediately to the new task.
|
|
1758
|
+
#
|
|
1759
|
+
# @yields {|task| ...} in the context of the new task.
|
|
1760
|
+
# @raises [FinishedError] If the task has already finished.
|
|
1761
|
+
# @returns [Task] The child task.
|
|
1762
|
+
#
|
|
1763
|
+
# pkg:gem/async#lib/async/task.rb:247
|
|
1764
|
+
def async(*arguments, **options, &block); end
|
|
1765
|
+
|
|
1766
|
+
# @returns [Array(Thread::Backtrace::Location) | Nil] The backtrace of the task, if available.
|
|
1767
|
+
#
|
|
1768
|
+
# pkg:gem/async#lib/async/task.rb:114
|
|
1769
|
+
def backtrace(*arguments); end
|
|
1770
|
+
|
|
1771
|
+
# Cancel the task and all of its children.
|
|
1772
|
+
#
|
|
1773
|
+
# If `later` is false, it means that `cancel` has been invoked directly. When `later` is true, it means that `cancel` is invoked by `stop_children` or some other indirect mechanism. In that case, if we encounter the "current" fiber, we can't cancel it right away, as it's currently performing `#cancel`. Cancelling it immediately would interrupt the current cancel traversal, so we need to schedule the cancel to occur later.
|
|
1774
|
+
#
|
|
1775
|
+
# @parameter later [Boolean] Whether to cancel the task later, or immediately.
|
|
1776
|
+
# @parameter cause [Exception] The cause of the cancel operation.
|
|
1777
|
+
#
|
|
1778
|
+
# pkg:gem/async#lib/async/task.rb:329
|
|
1779
|
+
def cancel(later = T.unsafe(nil), cause: T.unsafe(nil)); end
|
|
1780
|
+
|
|
1781
|
+
# @returns [Boolean] Whether cancel has been deferred.
|
|
1782
|
+
#
|
|
1783
|
+
# pkg:gem/async#lib/async/task.rb:429
|
|
1784
|
+
def cancel_deferred?; end
|
|
1785
|
+
|
|
1786
|
+
# @returns [Boolean] Whether the task has been cancelled.
|
|
1787
|
+
#
|
|
1788
|
+
# pkg:gem/async#lib/async/task.rb:188
|
|
1789
|
+
def cancelled?; end
|
|
1790
|
+
|
|
1791
|
+
# Alias for {#completed?}.
|
|
1792
|
+
#
|
|
1793
|
+
# pkg:gem/async#lib/async/task.rb:198
|
|
1794
|
+
def complete?; end
|
|
1795
|
+
|
|
1796
|
+
# @returns [Boolean] Whether the task has completed execution and generated a result.
|
|
1797
|
+
#
|
|
1798
|
+
# pkg:gem/async#lib/async/task.rb:193
|
|
1799
|
+
def completed?; end
|
|
1800
|
+
|
|
1801
|
+
# @returns [Boolean] Whether this task is the currently executing task.
|
|
1802
|
+
#
|
|
1803
|
+
# pkg:gem/async#lib/async/task.rb:453
|
|
1804
|
+
def current?; end
|
|
1805
|
+
|
|
1806
|
+
# Defer the handling of cancel. During the execution of the given block, if a cancel is requested, it will be deferred until the block exits. This is useful for ensuring graceful shutdown of servers and other long-running tasks. You should wrap the response handling code in a defer_cancel block to ensure that the task is cancelled when the response is complete but not before.
|
|
1807
|
+
#
|
|
1808
|
+
# You can nest calls to defer_cancel, but the cancel will only be deferred until the outermost block exits.
|
|
1809
|
+
#
|
|
1810
|
+
# If cancel is invoked a second time, it will be immediately executed.
|
|
1811
|
+
#
|
|
1812
|
+
# @yields {} The block of code to execute.
|
|
1813
|
+
# @public Since *Async v1*.
|
|
1814
|
+
#
|
|
1815
|
+
# pkg:gem/async#lib/async/task.rb:390
|
|
1816
|
+
def defer_cancel; end
|
|
1817
|
+
|
|
1818
|
+
# Backward compatibility alias for {#defer_cancel}.
|
|
1819
|
+
# @deprecated Use {#defer_cancel} instead.
|
|
1820
|
+
#
|
|
1821
|
+
# pkg:gem/async#lib/async/task.rb:424
|
|
1822
|
+
def defer_stop(&block); end
|
|
1823
|
+
|
|
1824
|
+
# @returns [Boolean] Whether the task failed with an exception.
|
|
1825
|
+
#
|
|
1826
|
+
# pkg:gem/async#lib/async/task.rb:183
|
|
1827
|
+
def failed?; end
|
|
1828
|
+
|
|
1829
|
+
# @attribute [Fiber] The fiber which is being used for the execution of this task.
|
|
1830
|
+
#
|
|
1831
|
+
# pkg:gem/async#lib/async/task.rb:163
|
|
1832
|
+
def fiber; end
|
|
1833
|
+
|
|
1834
|
+
# Whether we can remove this node from the reactor graph.
|
|
1835
|
+
# @returns [Boolean]
|
|
1836
|
+
#
|
|
1837
|
+
# pkg:gem/async#lib/async/task.rb:172
|
|
1838
|
+
def finished?; end
|
|
1839
|
+
|
|
1840
|
+
# For compatibility with `Thread#join` and similar interfaces.
|
|
1841
|
+
#
|
|
1842
|
+
# pkg:gem/async#lib/async/task.rb:280
|
|
1843
|
+
def join(*, **, &); end
|
|
1844
|
+
|
|
1845
|
+
# @returns [Scheduler] The scheduler for this task.
|
|
1846
|
+
#
|
|
1847
|
+
# pkg:gem/async#lib/async/task.rb:109
|
|
1848
|
+
def reactor; end
|
|
1849
|
+
|
|
1850
|
+
# Access the result of the task without waiting. May be nil if the task is not completed. Does not raise exceptions.
|
|
1851
|
+
#
|
|
1852
|
+
# pkg:gem/async#lib/async/task.rb:312
|
|
1853
|
+
def result; end
|
|
1854
|
+
|
|
1855
|
+
# Begin the execution of the task.
|
|
1856
|
+
#
|
|
1857
|
+
# @raises [RuntimeError] If the task is already running.
|
|
1858
|
+
#
|
|
1859
|
+
# pkg:gem/async#lib/async/task.rb:219
|
|
1860
|
+
def run(*arguments); end
|
|
1861
|
+
|
|
1862
|
+
# @returns [Boolean] Whether the task is running.
|
|
1863
|
+
#
|
|
1864
|
+
# pkg:gem/async#lib/async/task.rb:178
|
|
1865
|
+
def running?; end
|
|
1866
|
+
|
|
1867
|
+
# @deprecated Prefer {Kernel#sleep} except when compatibility with `stable-v1` is required.
|
|
1868
|
+
#
|
|
1869
|
+
# pkg:gem/async#lib/async/task.rb:146
|
|
1870
|
+
def sleep(duration = T.unsafe(nil)); end
|
|
1871
|
+
|
|
1872
|
+
# @attribute [Symbol] The status of the execution of the task, one of `:initialized`, `:running`, `:complete`, `:cancelled` or `:failed`.
|
|
1873
|
+
#
|
|
1874
|
+
# pkg:gem/async#lib/async/task.rb:203
|
|
1875
|
+
def status; end
|
|
1876
|
+
|
|
1877
|
+
# Backward compatibility alias for {#cancel_deferred?}.
|
|
1878
|
+
# @deprecated Use {#cancel_deferred?} instead.
|
|
1879
|
+
#
|
|
1880
|
+
# pkg:gem/async#lib/async/task.rb:435
|
|
1881
|
+
def stop_deferred?; end
|
|
1882
|
+
|
|
1883
|
+
# @returns [String] A description of the task and it's current status.
|
|
1884
|
+
#
|
|
1885
|
+
# pkg:gem/async#lib/async/task.rb:141
|
|
1886
|
+
def to_s; end
|
|
1887
|
+
|
|
1888
|
+
# Retrieve the current result of the task. Will cause the caller to wait until result is available. If the task resulted in an unhandled error (derived from `StandardError`), this will be raised. If the task was cancelled, this will return `nil`.
|
|
1889
|
+
#
|
|
1890
|
+
# Conceptually speaking, waiting on a task should return a result, and if it throws an exception, this is certainly an exceptional case that should represent a failure in your program, not an expected outcome. In other words, you should not design your programs to expect exceptions from `#wait` as a normal flow control, and prefer to catch known exceptions within the task itself and return a result that captures the intention of the failure, e.g. a `TimeoutError` might simply return `nil` or `false` to indicate that the operation did not generate a valid result (as a timeout was an expected outcome of the internal operation in this case).
|
|
1891
|
+
#
|
|
1892
|
+
# @parameter timeout [Numeric] The maximum number of seconds to wait for the result before raising a `TimeoutError`, if specified.
|
|
1893
|
+
# @raises [RuntimeError] If the task's fiber is the current fiber.
|
|
1894
|
+
# @returns [Object] The final expression/result of the task's block.
|
|
1895
|
+
# @asynchronous This method is thread-safe.
|
|
1896
|
+
#
|
|
1897
|
+
# pkg:gem/async#lib/async/task.rb:272
|
|
1898
|
+
def wait(*, **, &); end
|
|
1899
|
+
|
|
1900
|
+
# Wait on all non-transient children to complete, recursively, then wait on the task itself, if it is not the current task.
|
|
1901
|
+
#
|
|
1902
|
+
# If any child task fails with an exception, that exception will be raised immediately, and remaining children may not be waited on.
|
|
1903
|
+
#
|
|
1904
|
+
# @example Waiting on all children.
|
|
1905
|
+
# Async do |task|
|
|
1906
|
+
# child = task.async do
|
|
1907
|
+
# sleep(0.01)
|
|
1908
|
+
# end
|
|
1909
|
+
# task.wait_all # Will wait on the child task.
|
|
1910
|
+
# end
|
|
1911
|
+
#
|
|
1912
|
+
# @raises [StandardError] If any child task failed with an exception, that exception will be raised.
|
|
1913
|
+
# @returns [Object | Nil] The final expression/result of the task's block, or nil if called from within the task.
|
|
1914
|
+
# @asynchronous This method is thread-safe.
|
|
1915
|
+
#
|
|
1916
|
+
# pkg:gem/async#lib/async/task.rb:297
|
|
1917
|
+
def wait_all; end
|
|
1918
|
+
|
|
1919
|
+
# Execute the given block of code, raising the specified exception if it exceeds the given duration during a non-blocking operation.
|
|
1920
|
+
#
|
|
1921
|
+
# pkg:gem/async#lib/async/task.rb:153
|
|
1922
|
+
def with_timeout(duration, exception = T.unsafe(nil), message = T.unsafe(nil), &block); end
|
|
1923
|
+
|
|
1924
|
+
# Yield back to the reactor and allow other fibers to execute.
|
|
1925
|
+
#
|
|
1926
|
+
# pkg:gem/async#lib/async/task.rb:158
|
|
1927
|
+
def yield; end
|
|
1928
|
+
|
|
1929
|
+
private
|
|
1930
|
+
|
|
1931
|
+
# pkg:gem/async#lib/async/task.rb:515
|
|
1932
|
+
def cancel!(cause = T.unsafe(nil)); end
|
|
1933
|
+
|
|
1934
|
+
# pkg:gem/async#lib/async/task.rb:488
|
|
1935
|
+
def cancelled!(cause = T.unsafe(nil)); end
|
|
1936
|
+
|
|
1937
|
+
# State transition into the completed state.
|
|
1938
|
+
#
|
|
1939
|
+
# pkg:gem/async#lib/async/task.rb:477
|
|
1940
|
+
def completed!(result); end
|
|
1941
|
+
|
|
1942
|
+
# State transition into the failed state.
|
|
1943
|
+
#
|
|
1944
|
+
# pkg:gem/async#lib/async/task.rb:483
|
|
1945
|
+
def failed!(exception = T.unsafe(nil)); end
|
|
1946
|
+
|
|
1947
|
+
# Finish the current task, moving any children to the parent.
|
|
1948
|
+
#
|
|
1949
|
+
# pkg:gem/async#lib/async/task.rb:464
|
|
1950
|
+
def finish!; end
|
|
1951
|
+
|
|
1952
|
+
# pkg:gem/async#lib/async/task.rb:525
|
|
1953
|
+
def schedule(&block); end
|
|
1954
|
+
|
|
1955
|
+
# pkg:gem/async#lib/async/task.rb:521
|
|
1956
|
+
def stop!; end
|
|
1957
|
+
|
|
1958
|
+
# pkg:gem/async#lib/async/task.rb:511
|
|
1959
|
+
def stopped!; end
|
|
1960
|
+
|
|
1961
|
+
# pkg:gem/async#lib/async/task.rb:459
|
|
1962
|
+
def warn(*, **, &); end
|
|
1963
|
+
|
|
1964
|
+
class << self
|
|
1965
|
+
# Lookup the {Task} for the current fiber. Raise `RuntimeError` if none is available.
|
|
1966
|
+
# @returns [Task]
|
|
1967
|
+
# @raises[RuntimeError] If task was not {set!} for the current fiber.
|
|
1968
|
+
#
|
|
1969
|
+
# pkg:gem/async#lib/async/task.rb:442
|
|
1970
|
+
def current; end
|
|
1971
|
+
|
|
1972
|
+
# Check if there is a task defined for the current fiber.
|
|
1973
|
+
# @returns [Interface(:async) | Nil]
|
|
1974
|
+
#
|
|
1975
|
+
# pkg:gem/async#lib/async/task.rb:448
|
|
1976
|
+
def current?; end
|
|
1977
|
+
|
|
1978
|
+
# Run the given block of code in a task, asynchronously, in the given scheduler.
|
|
1979
|
+
#
|
|
1980
|
+
# pkg:gem/async#lib/async/task.rb:71
|
|
1981
|
+
def run(scheduler, *arguments, **options, &block); end
|
|
1982
|
+
|
|
1983
|
+
# @deprecated With no replacement.
|
|
1984
|
+
#
|
|
1985
|
+
# pkg:gem/async#lib/async/task.rb:64
|
|
1986
|
+
def yield; end
|
|
1987
|
+
end
|
|
1988
|
+
end
|
|
1989
|
+
|
|
1990
|
+
# Raised when a child task is created within a task that has finished execution.
|
|
1991
|
+
#
|
|
1992
|
+
# pkg:gem/async#lib/async/task.rb:54
|
|
1993
|
+
class Async::Task::FinishedError < ::RuntimeError
|
|
1994
|
+
# Create a new finished error.
|
|
1995
|
+
#
|
|
1996
|
+
# @parameter message [String] The error message.
|
|
1997
|
+
#
|
|
1998
|
+
# pkg:gem/async#lib/async/task.rb:58
|
|
1999
|
+
def initialize(message = T.unsafe(nil)); end
|
|
2000
|
+
end
|
|
2001
|
+
|
|
2002
|
+
# Represents a flexible timeout that can be rescheduled or extended.
|
|
2003
|
+
# @public Since *Async v2.24*.
|
|
2004
|
+
#
|
|
2005
|
+
# pkg:gem/async#lib/async/timeout.rb:9
|
|
2006
|
+
class Async::Timeout
|
|
2007
|
+
# Initialize a new timeout.
|
|
2008
|
+
#
|
|
2009
|
+
# pkg:gem/async#lib/async/timeout.rb:11
|
|
2010
|
+
def initialize(timers, handle); end
|
|
2011
|
+
|
|
2012
|
+
# Adjust the timeout by the specified duration.
|
|
2013
|
+
#
|
|
2014
|
+
# The duration is relative to the timeout time, e.g. adjusting the timeout by 5 increases the current duration by 5 seconds.
|
|
2015
|
+
#
|
|
2016
|
+
# @parameter duration [Numeric] The duration to adjust the timeout by, in seconds.
|
|
2017
|
+
# @returns [Numeric] The new time at which the timeout will occur.
|
|
2018
|
+
#
|
|
2019
|
+
# pkg:gem/async#lib/async/timeout.rb:36
|
|
2020
|
+
def adjust(duration); end
|
|
2021
|
+
|
|
2022
|
+
# Cancel the timeout, preventing it from executing.
|
|
2023
|
+
#
|
|
2024
|
+
# pkg:gem/async#lib/async/timeout.rb:59
|
|
2025
|
+
def cancel!; end
|
|
2026
|
+
|
|
2027
|
+
# @returns [Boolean] Whether the timeout has been cancelled.
|
|
2028
|
+
#
|
|
2029
|
+
# pkg:gem/async#lib/async/timeout.rb:64
|
|
2030
|
+
def cancelled?; end
|
|
2031
|
+
|
|
2032
|
+
# @returns [Numeric] The time remaining until the timeout occurs, in seconds.
|
|
2033
|
+
#
|
|
2034
|
+
# pkg:gem/async#lib/async/timeout.rb:17
|
|
2035
|
+
def duration; end
|
|
2036
|
+
|
|
2037
|
+
# Update the duration of the timeout.
|
|
2038
|
+
#
|
|
2039
|
+
# The duration is relative to the current time, e.g. setting the duration to 5 means the timeout will occur in 5 seconds from now.
|
|
2040
|
+
#
|
|
2041
|
+
# @parameter value [Numeric] The new duration to assign to the timeout, in seconds.
|
|
2042
|
+
#
|
|
2043
|
+
# pkg:gem/async#lib/async/timeout.rb:26
|
|
2044
|
+
def duration=(value); end
|
|
2045
|
+
|
|
2046
|
+
# @returns [Numeric] The current time in the scheduler, relative to the time of this timeout, in seconds.
|
|
2047
|
+
#
|
|
2048
|
+
# pkg:gem/async#lib/async/timeout.rb:54
|
|
2049
|
+
def now; end
|
|
2050
|
+
|
|
2051
|
+
# @returns [Numeric] The time at which the timeout will occur, in seconds since {now}.
|
|
2052
|
+
#
|
|
2053
|
+
# pkg:gem/async#lib/async/timeout.rb:41
|
|
2054
|
+
def time; end
|
|
2055
|
+
|
|
2056
|
+
# Assign a new time to the timeout, rescheduling it if necessary.
|
|
2057
|
+
#
|
|
2058
|
+
# @parameter value [Numeric] The new time to assign to the timeout.
|
|
2059
|
+
# @returns [Numeric] The new time at which the timeout will occur.
|
|
2060
|
+
#
|
|
2061
|
+
# pkg:gem/async#lib/async/timeout.rb:49
|
|
2062
|
+
def time=(value); end
|
|
2063
|
+
|
|
2064
|
+
private
|
|
2065
|
+
|
|
2066
|
+
# Reschedule the timeout to occur at the specified time.
|
|
2067
|
+
#
|
|
2068
|
+
# @parameter time [Numeric] The new time to schedule the timeout for.
|
|
2069
|
+
# @returns [Numeric] The new time at which the timeout will occur.
|
|
2070
|
+
#
|
|
2071
|
+
# pkg:gem/async#lib/async/timeout.rb:76
|
|
2072
|
+
def reschedule(time); end
|
|
2073
|
+
end
|
|
2074
|
+
|
|
2075
|
+
# Raised when attempting to reschedule a cancelled timeout.
|
|
2076
|
+
#
|
|
2077
|
+
# pkg:gem/async#lib/async/timeout.rb:69
|
|
2078
|
+
class Async::Timeout::CancelledError < ::RuntimeError; end
|
|
2079
|
+
|
|
2080
|
+
# Raised if a timeout occurs on a specific Fiber. Handled gracefully by `Task`.
|
|
2081
|
+
# @public Since *Async v1*.
|
|
2082
|
+
#
|
|
2083
|
+
# pkg:gem/async#lib/async/error.rb:9
|
|
2084
|
+
class Async::TimeoutError < ::StandardError
|
|
2085
|
+
# Create a new timeout error.
|
|
2086
|
+
#
|
|
2087
|
+
# @parameter message [String] The error message.
|
|
2088
|
+
#
|
|
2089
|
+
# pkg:gem/async#lib/async/error.rb:13
|
|
2090
|
+
def initialize(message = T.unsafe(nil)); end
|
|
2091
|
+
end
|
|
2092
|
+
|
|
2093
|
+
# pkg:gem/async#lib/async/version.rb:8
|
|
2094
|
+
Async::VERSION = T.let(T.unsafe(nil), String)
|
|
2095
|
+
|
|
2096
|
+
# A synchronization primitive that allows one task to wait for another task to resolve a value.
|
|
2097
|
+
#
|
|
2098
|
+
# @deprecated Use {Async::Promise} instead.
|
|
2099
|
+
#
|
|
2100
|
+
# pkg:gem/async#lib/async/variable.rb:13
|
|
2101
|
+
class Async::Variable
|
|
2102
|
+
# Create a new variable.
|
|
2103
|
+
#
|
|
2104
|
+
# @parameter condition [Condition] The condition to use for synchronization.
|
|
2105
|
+
#
|
|
2106
|
+
# pkg:gem/async#lib/async/variable.rb:17
|
|
2107
|
+
def initialize(condition = T.unsafe(nil)); end
|
|
2108
|
+
|
|
2109
|
+
# Resolve the value.
|
|
2110
|
+
#
|
|
2111
|
+
# Signals all waiting tasks.
|
|
2112
|
+
#
|
|
2113
|
+
# @parameter value [Object] The value to resolve.
|
|
2114
|
+
#
|
|
2115
|
+
# pkg:gem/async#lib/async/variable.rb:29
|
|
2116
|
+
def resolve(value = T.unsafe(nil)); end
|
|
2117
|
+
|
|
2118
|
+
# Whether the value has been resolved.
|
|
2119
|
+
#
|
|
2120
|
+
# @returns [Boolean] Whether the value has been resolved.
|
|
2121
|
+
#
|
|
2122
|
+
# pkg:gem/async#lib/async/variable.rb:47
|
|
2123
|
+
def resolved?; end
|
|
2124
|
+
|
|
2125
|
+
# Alias for {#wait}.
|
|
2126
|
+
#
|
|
2127
|
+
# pkg:gem/async#lib/async/variable.rb:60
|
|
2128
|
+
def value; end
|
|
2129
|
+
|
|
2130
|
+
# Alias for {#resolve}.
|
|
2131
|
+
#
|
|
2132
|
+
# pkg:gem/async#lib/async/variable.rb:40
|
|
2133
|
+
def value=(value); end
|
|
2134
|
+
|
|
2135
|
+
# Wait for the value to be resolved.
|
|
2136
|
+
#
|
|
2137
|
+
# @returns [Object] The resolved value.
|
|
2138
|
+
#
|
|
2139
|
+
# pkg:gem/async#lib/async/variable.rb:54
|
|
2140
|
+
def wait; end
|
|
2141
|
+
end
|
|
2142
|
+
|
|
2143
|
+
# Extensions to all Ruby objects.
|
|
2144
|
+
#
|
|
2145
|
+
# pkg:gem/async#lib/kernel/async.rb:9
|
|
2146
|
+
module Kernel
|
|
2147
|
+
# Run the given block of code in a task, asynchronously, creating a reactor if necessary.
|
|
2148
|
+
#
|
|
2149
|
+
# The preferred method to invoke asynchronous behavior at the top level.
|
|
2150
|
+
#
|
|
2151
|
+
# - When invoked within an existing reactor task, it will run the given block
|
|
2152
|
+
# asynchronously. Will return the task once it has been scheduled.
|
|
2153
|
+
# - When invoked at the top level, will create and run a reactor, and invoke
|
|
2154
|
+
# the block as an asynchronous task. Will block until the reactor finishes
|
|
2155
|
+
# running.
|
|
2156
|
+
#
|
|
2157
|
+
# @yields {|task| ...} The block that will execute asynchronously.
|
|
2158
|
+
# @parameter task [Async::Task] The task that is executing the given block.
|
|
2159
|
+
#
|
|
2160
|
+
# @public Since *Async v1*.
|
|
2161
|
+
# @asynchronous May block until given block completes executing.
|
|
2162
|
+
#
|
|
2163
|
+
# pkg:gem/async#lib/kernel/async.rb:25
|
|
2164
|
+
def Async(*, **, &); end
|
|
2165
|
+
|
|
2166
|
+
# Create a barrier, yield it to the block, and then wait for all tasks to complete.
|
|
2167
|
+
#
|
|
2168
|
+
# If no scheduler is running, one will be created automatically for the duration of the block.
|
|
2169
|
+
#
|
|
2170
|
+
# By default, the barrier uses an `Async::Idler` to manage load, but this can be overridden by providing a different parent or `nil` to disable load management.
|
|
2171
|
+
#
|
|
2172
|
+
# @parameter parent [Task | Semaphore | Nil] The parent for holding any children tasks.
|
|
2173
|
+
# @parameter **options [Hash] Additional options passed to {Kernel::Sync}.
|
|
2174
|
+
# @public Since *Async v2.34*.
|
|
2175
|
+
#
|
|
2176
|
+
# pkg:gem/async#lib/kernel/barrier.rb:20
|
|
2177
|
+
def Barrier(parent: T.unsafe(nil), **options); end
|
|
2178
|
+
|
|
2179
|
+
# Run the given block of code synchronously, but within a reactor if not already in one.
|
|
2180
|
+
#
|
|
2181
|
+
# @yields {|task| ...} The block that will execute asynchronously.
|
|
2182
|
+
# @parameter task [Async::Task] The task that is executing the given block.
|
|
2183
|
+
#
|
|
2184
|
+
# @public Since *Async v1*.
|
|
2185
|
+
# @asynchronous Will block until given block completes executing.
|
|
2186
|
+
#
|
|
2187
|
+
# pkg:gem/async#lib/kernel/sync.rb:20
|
|
2188
|
+
def Sync(annotation: T.unsafe(nil), &block); end
|
|
2189
|
+
end
|
|
2190
|
+
|
|
2191
|
+
module Process
|
|
2192
|
+
extend ::Async::ForkHandler
|
|
2193
|
+
end
|