roast-ai 0.4.10 → 0.5.1

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.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/commands/docs/write-comments.md +36 -0
  3. data/.github/CODEOWNERS +1 -1
  4. data/.github/workflows/ci.yaml +10 -6
  5. data/.gitignore +0 -1
  6. data/.rubocop.yml +7 -1
  7. data/.ruby-version +1 -1
  8. data/CLAUDE.md +2 -2
  9. data/CONTRIBUTING.md +2 -0
  10. data/Gemfile +19 -18
  11. data/Gemfile.lock +35 -58
  12. data/README.md +118 -1432
  13. data/README_LEGACY.md +1464 -0
  14. data/Rakefile +39 -4
  15. data/dev.yml +29 -0
  16. data/dsl/agent_sessions.rb +20 -0
  17. data/dsl/async_cogs.rb +49 -0
  18. data/dsl/async_cogs_complex.rb +67 -0
  19. data/dsl/call.rb +44 -0
  20. data/dsl/collect_from.rb +72 -0
  21. data/dsl/json_output.rb +28 -0
  22. data/dsl/map.rb +55 -0
  23. data/dsl/map_reduce.rb +37 -0
  24. data/dsl/map_with_index.rb +49 -0
  25. data/dsl/next_break.rb +45 -0
  26. data/dsl/next_break_parallel.rb +44 -0
  27. data/dsl/outputs.rb +39 -0
  28. data/dsl/outputs_bang.rb +36 -0
  29. data/dsl/parallel_map.rb +37 -0
  30. data/dsl/prompts/simple_prompt.md.erb +3 -0
  31. data/dsl/prototype.rb +5 -7
  32. data/dsl/repeat_loop_results.rb +53 -0
  33. data/dsl/ruby_cog.rb +72 -0
  34. data/dsl/simple_agent.rb +18 -0
  35. data/dsl/simple_chat.rb +15 -1
  36. data/dsl/simple_repeat.rb +29 -0
  37. data/dsl/skip.rb +36 -0
  38. data/dsl/step_communication.rb +2 -3
  39. data/dsl/targets_and_params.rb +57 -0
  40. data/dsl/temperature.rb +17 -0
  41. data/dsl/temporary_directory.rb +22 -0
  42. data/dsl/tutorial/01_your_first_workflow/README.md +179 -0
  43. data/dsl/tutorial/01_your_first_workflow/configured_chat.rb +33 -0
  44. data/dsl/tutorial/01_your_first_workflow/hello.rb +23 -0
  45. data/dsl/tutorial/02_chaining_cogs/README.md +310 -0
  46. data/dsl/tutorial/02_chaining_cogs/code_review.rb +104 -0
  47. data/dsl/tutorial/02_chaining_cogs/session_resumption.rb +92 -0
  48. data/dsl/tutorial/02_chaining_cogs/simple_chain.rb +84 -0
  49. data/dsl/tutorial/03_targets_and_params/README.md +230 -0
  50. data/dsl/tutorial/03_targets_and_params/multiple_targets.rb +65 -0
  51. data/dsl/tutorial/03_targets_and_params/single_target.rb +65 -0
  52. data/dsl/tutorial/04_configuration_options/README.md +209 -0
  53. data/dsl/tutorial/04_configuration_options/control_display_and_temperature.rb +104 -0
  54. data/dsl/tutorial/04_configuration_options/simple_config.rb +68 -0
  55. data/dsl/tutorial/05_control_flow/README.md +156 -0
  56. data/dsl/tutorial/05_control_flow/conditional_execution.rb +62 -0
  57. data/dsl/tutorial/05_control_flow/handling_failures.rb +77 -0
  58. data/dsl/tutorial/06_reusable_scopes/README.md +172 -0
  59. data/dsl/tutorial/06_reusable_scopes/accessing_scope_outputs.rb +126 -0
  60. data/dsl/tutorial/06_reusable_scopes/basic_scope.rb +63 -0
  61. data/dsl/tutorial/06_reusable_scopes/parameterized_scope.rb +78 -0
  62. data/dsl/tutorial/07_processing_collections/README.md +152 -0
  63. data/dsl/tutorial/07_processing_collections/basic_map.rb +70 -0
  64. data/dsl/tutorial/07_processing_collections/parallel_map.rb +74 -0
  65. data/dsl/tutorial/08_iterative_workflows/README.md +231 -0
  66. data/dsl/tutorial/08_iterative_workflows/basic_repeat.rb +57 -0
  67. data/dsl/tutorial/08_iterative_workflows/conditional_break.rb +57 -0
  68. data/dsl/tutorial/09_async_cogs/README.md +197 -0
  69. data/dsl/tutorial/09_async_cogs/basic_async.rb +38 -0
  70. data/dsl/tutorial/README.md +222 -0
  71. data/dsl/working_directory.rb +16 -0
  72. data/exe/roast +1 -1
  73. data/internal/documentation/architectural-notes.md +115 -0
  74. data/internal/documentation/doc-comments-external.md +686 -0
  75. data/internal/documentation/doc-comments-internal.md +342 -0
  76. data/internal/documentation/doc-comments.md +211 -0
  77. data/lib/roast/dsl/cog/config.rb +274 -3
  78. data/lib/roast/dsl/cog/input.rb +53 -10
  79. data/lib/roast/dsl/cog/output.rb +297 -8
  80. data/lib/roast/dsl/cog/registry.rb +35 -3
  81. data/lib/roast/dsl/cog/stack.rb +1 -1
  82. data/lib/roast/dsl/cog/store.rb +5 -5
  83. data/lib/roast/dsl/cog.rb +70 -14
  84. data/lib/roast/dsl/cog_input_context.rb +36 -1
  85. data/lib/roast/dsl/cog_input_manager.rb +116 -7
  86. data/lib/roast/dsl/cogs/agent/config.rb +465 -0
  87. data/lib/roast/dsl/cogs/agent/input.rb +81 -0
  88. data/lib/roast/dsl/cogs/agent/output.rb +59 -0
  89. data/lib/roast/dsl/cogs/agent/provider.rb +51 -0
  90. data/lib/roast/dsl/cogs/agent/providers/claude/claude_invocation.rb +185 -0
  91. data/lib/roast/dsl/cogs/agent/providers/claude/message.rb +73 -0
  92. data/lib/roast/dsl/cogs/agent/providers/claude/messages/assistant_message.rb +36 -0
  93. data/lib/roast/dsl/cogs/agent/providers/claude/messages/result_message.rb +61 -0
  94. data/lib/roast/dsl/cogs/agent/providers/claude/messages/system_message.rb +47 -0
  95. data/lib/roast/dsl/cogs/agent/providers/claude/messages/text_message.rb +36 -0
  96. data/lib/roast/dsl/cogs/agent/providers/claude/messages/tool_result_message.rb +47 -0
  97. data/lib/roast/dsl/cogs/agent/providers/claude/messages/tool_use_message.rb +46 -0
  98. data/lib/roast/dsl/cogs/agent/providers/claude/messages/unknown_message.rb +27 -0
  99. data/lib/roast/dsl/cogs/agent/providers/claude/messages/user_message.rb +37 -0
  100. data/lib/roast/dsl/cogs/agent/providers/claude/tool_result.rb +51 -0
  101. data/lib/roast/dsl/cogs/agent/providers/claude/tool_use.rb +48 -0
  102. data/lib/roast/dsl/cogs/agent/providers/claude.rb +31 -0
  103. data/lib/roast/dsl/cogs/agent/stats.rb +92 -0
  104. data/lib/roast/dsl/cogs/agent/usage.rb +62 -0
  105. data/lib/roast/dsl/cogs/agent.rb +75 -0
  106. data/lib/roast/dsl/cogs/chat/config.rb +453 -0
  107. data/lib/roast/dsl/cogs/chat/input.rb +92 -0
  108. data/lib/roast/dsl/cogs/chat/output.rb +64 -0
  109. data/lib/roast/dsl/cogs/chat/session.rb +68 -0
  110. data/lib/roast/dsl/cogs/chat.rb +59 -56
  111. data/lib/roast/dsl/cogs/cmd.rb +251 -61
  112. data/lib/roast/dsl/cogs/ruby.rb +171 -0
  113. data/lib/roast/dsl/command_runner.rb +191 -0
  114. data/lib/roast/dsl/config_manager.rb +58 -11
  115. data/lib/roast/dsl/control_flow.rb +41 -0
  116. data/lib/roast/dsl/execution_manager.rb +162 -32
  117. data/lib/roast/dsl/nil_assertions.rb +23 -0
  118. data/lib/roast/dsl/system_cog/params.rb +32 -0
  119. data/lib/roast/dsl/system_cog.rb +36 -0
  120. data/lib/roast/dsl/system_cogs/call.rb +163 -0
  121. data/lib/roast/dsl/system_cogs/map.rb +454 -0
  122. data/lib/roast/dsl/system_cogs/repeat.rb +242 -0
  123. data/lib/roast/dsl/workflow.rb +26 -16
  124. data/lib/roast/dsl/workflow_context.rb +20 -0
  125. data/lib/roast/dsl/workflow_params.rb +24 -0
  126. data/lib/roast/helpers/minitest_coverage_runner.rb +1 -1
  127. data/lib/roast/sorbet_runtime_stub.rb +154 -0
  128. data/lib/roast/tools/apply_diff.rb +1 -3
  129. data/lib/roast/tools/cmd.rb +4 -3
  130. data/lib/roast/tools/read_file.rb +1 -1
  131. data/lib/roast/tools/update_files.rb +1 -1
  132. data/lib/roast/tools/write_file.rb +1 -1
  133. data/lib/roast/version.rb +1 -1
  134. data/lib/roast/workflow/base_workflow.rb +4 -0
  135. data/lib/roast/workflow/step_loader.rb +14 -2
  136. data/lib/roast-ai.rb +4 -0
  137. data/lib/roast.rb +58 -21
  138. data/{roast.gemspec → roast-ai.gemspec} +9 -13
  139. data/sorbet/rbi/gems/async@2.34.0.rbi +1577 -0
  140. data/sorbet/rbi/gems/cli-kit@5.2.0.rbi +2063 -0
  141. data/sorbet/rbi/gems/{cli-ui@2.3.0.rbi → cli-ui@2.7.0-6bdefd1d06305e5d6ae312ac76f9c88f88658dda.rbi} +1418 -1013
  142. data/sorbet/rbi/gems/console@1.34.2.rbi +1193 -0
  143. data/sorbet/rbi/gems/fiber-annotation@0.2.0.rbi +50 -0
  144. data/sorbet/rbi/gems/fiber-local@1.1.0.rbi +35 -0
  145. data/sorbet/rbi/gems/fiber-storage@1.0.1.rbi +41 -0
  146. data/sorbet/rbi/gems/io-event@1.14.0.rbi +724 -0
  147. data/sorbet/rbi/gems/metrics@0.15.0.rbi +9 -0
  148. data/sorbet/rbi/gems/traces@0.18.2.rbi +9 -0
  149. data/sorbet/rbi/shims/lib/roast/dsl/cog_input_context.rbi +1185 -5
  150. data/sorbet/rbi/shims/lib/roast/dsl/config_context.rbi +311 -5
  151. data/sorbet/rbi/shims/lib/roast/dsl/execution_context.rbi +486 -5
  152. data/sorbet/tapioca/config.yml +6 -0
  153. data/sorbet/tapioca/require.rb +2 -0
  154. metadata +157 -30
  155. data/dsl/less_simple.rb +0 -112
  156. data/dsl/scoped_executors.rb +0 -28
  157. data/dsl/simple.rb +0 -8
  158. data/lib/roast/dsl/cogs/execute.rb +0 -46
  159. data/lib/roast/dsl/cogs/graph.rb +0 -53
  160. data/sorbet/rbi/gems/cgi@0.5.0.rbi +0 -2961
  161. data/sorbet/rbi/gems/claude_swarm@0.1.19.rbi +0 -568
  162. data/sorbet/rbi/gems/cli-kit@5.0.1.rbi +0 -1991
  163. data/sorbet/rbi/gems/dry-configurable@1.3.0.rbi +0 -672
  164. data/sorbet/rbi/gems/dry-core@1.1.0.rbi +0 -1894
  165. data/sorbet/rbi/gems/dry-inflector@1.2.0.rbi +0 -659
  166. data/sorbet/rbi/gems/dry-initializer@3.2.0.rbi +0 -781
  167. data/sorbet/rbi/gems/dry-logic@1.6.0.rbi +0 -1127
  168. data/sorbet/rbi/gems/dry-schema@1.14.1.rbi +0 -3727
  169. data/sorbet/rbi/gems/dry-types@1.8.3.rbi +0 -3969
  170. data/sorbet/rbi/gems/fast-mcp-annotations@1.5.3.rbi +0 -1588
  171. data/sorbet/rbi/gems/mime-types-data@3.2025.0617.rbi +0 -136
  172. data/sorbet/rbi/gems/mime-types@3.7.0.rbi +0 -1342
  173. data/sorbet/rbi/gems/rack@2.2.19.rbi +0 -5676
  174. data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +0 -435
  175. data/sorbet/rbi/gems/yard@0.9.37.rbi +0 -18492
@@ -0,0 +1,1577 @@
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
+ # Asynchronous programming framework.
9
+ #
10
+ # source://async//lib/async/version.rb#6
11
+ module Async; end
12
+
13
+ # 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}.
14
+ #
15
+ # source://async//lib/async/barrier.rb#14
16
+ class Async::Barrier
17
+ # Initialize the barrier.
18
+ #
19
+ # @return [Barrier] a new instance of Barrier
20
+ #
21
+ # source://async//lib/async/barrier.rb#18
22
+ def initialize(parent: T.unsafe(nil)); end
23
+
24
+ # Execute a child task and add it to the barrier.
25
+ #
26
+ # source://async//lib/async/barrier.rb#45
27
+ def async(*arguments, parent: T.unsafe(nil), **options, &block); end
28
+
29
+ # Whether there are any tasks being held by the barrier.
30
+ #
31
+ # @return [Boolean]
32
+ #
33
+ # source://async//lib/async/barrier.rb#61
34
+ def empty?; end
35
+
36
+ # Number of tasks being held by the barrier.
37
+ #
38
+ # source://async//lib/async/barrier.rb#36
39
+ def size; end
40
+
41
+ # Stop all tasks held by the barrier.
42
+ #
43
+ # source://async//lib/async/barrier.rb#93
44
+ def stop; end
45
+
46
+ # All tasks which have been invoked into the barrier.
47
+ #
48
+ # source://async//lib/async/barrier.rb#41
49
+ def tasks; end
50
+
51
+ # 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.
52
+ #
53
+ # source://async//lib/async/barrier.rb#70
54
+ def wait; end
55
+ end
56
+
57
+ # source://async//lib/async/barrier.rb#25
58
+ class Async::Barrier::TaskNode < ::Async::List::Node
59
+ # @return [TaskNode] a new instance of TaskNode
60
+ #
61
+ # source://async//lib/async/barrier.rb#26
62
+ def initialize(task); end
63
+
64
+ # Returns the value of attribute task.
65
+ #
66
+ # source://async//lib/async/barrier.rb#30
67
+ def task; end
68
+ end
69
+
70
+ # A list of children tasks.
71
+ #
72
+ # source://async//lib/async/node.rb#15
73
+ class Async::Children < ::Async::List
74
+ # Create an empty list of children tasks.
75
+ #
76
+ # @return [Children] a new instance of Children
77
+ #
78
+ # source://async//lib/async/node.rb#17
79
+ def initialize; end
80
+
81
+ # Adjust the number of transient children, assuming it has changed.
82
+ #
83
+ # Despite being public, this is not intended to be called directly. It is used internally by {Node#transient=}.
84
+ #
85
+ # source://async//lib/async/node.rb#43
86
+ def adjust_transient_count(transient); end
87
+
88
+ # Whether all children are considered finished. Ignores transient children.
89
+ #
90
+ # @return [Boolean]
91
+ #
92
+ # source://async//lib/async/node.rb#29
93
+ def finished?; end
94
+
95
+ # Whether the children is empty, preserved for compatibility.
96
+ #
97
+ # @return [Boolean]
98
+ #
99
+ # source://async//lib/async/node.rb#34
100
+ def nil?; end
101
+
102
+ # Some children may be marked as transient. Transient children do not prevent the parent from finishing.
103
+ #
104
+ # @return [Boolean]
105
+ #
106
+ # source://async//lib/async/node.rb#24
107
+ def transients?; end
108
+
109
+ private
110
+
111
+ # source://async//lib/async/node.rb#53
112
+ def added(node); end
113
+
114
+ # source://async//lib/async/node.rb#61
115
+ def removed(node); end
116
+ end
117
+
118
+ # A convenient wrapper around the internal monotonic clock.
119
+ #
120
+ # source://async//lib/async/clock.rb#9
121
+ class Async::Clock
122
+ # Create a new clock with the initial total time.
123
+ #
124
+ # @return [Clock] a new instance of Clock
125
+ #
126
+ # source://async//lib/async/clock.rb#34
127
+ def initialize(total = T.unsafe(nil)); end
128
+
129
+ # Reset the total elapsed time. If the clock is currently running, reset the start time to now.
130
+ #
131
+ # source://async//lib/async/clock.rb#66
132
+ def reset!; end
133
+
134
+ # Start measuring a duration.
135
+ #
136
+ # source://async//lib/async/clock.rb#40
137
+ def start!; end
138
+
139
+ # Stop measuring a duration and append the duration to the current total.
140
+ #
141
+ # source://async//lib/async/clock.rb#45
142
+ def stop!; end
143
+
144
+ # The total elapsed time including any current duration.
145
+ #
146
+ # source://async//lib/async/clock.rb#55
147
+ def total; end
148
+
149
+ class << self
150
+ # Measure the execution of a block of code.
151
+ #
152
+ # source://async//lib/async/clock.rb#18
153
+ def measure; end
154
+
155
+ # Get the current elapsed monotonic time.
156
+ #
157
+ # source://async//lib/async/clock.rb#11
158
+ def now; end
159
+
160
+ # Start measuring elapsed time from now.
161
+ #
162
+ # source://async//lib/async/clock.rb#28
163
+ def start; end
164
+ end
165
+ end
166
+
167
+ # A synchronization primitive, which allows fibers to wait until a particular condition is (edge) triggered.
168
+ #
169
+ # source://async//lib/async/condition.rb#13
170
+ class Async::Condition
171
+ # Create a new condition.
172
+ #
173
+ # @return [Condition] a new instance of Condition
174
+ #
175
+ # source://async//lib/async/condition.rb#15
176
+ def initialize; end
177
+
178
+ # @return [Boolean]
179
+ #
180
+ # source://async//lib/async/condition.rb#26
181
+ def empty?; end
182
+
183
+ # Signal to a given task that it should resume operations.
184
+ #
185
+ # source://async//lib/async/condition.rb#37
186
+ def signal(value = T.unsafe(nil)); end
187
+
188
+ # Queue up the current fiber and wait on yielding the task.
189
+ #
190
+ # source://async//lib/async/condition.rb#21
191
+ def wait; end
192
+
193
+ # @return [Boolean]
194
+ #
195
+ # source://async//lib/async/condition.rb#31
196
+ def waiting?; end
197
+
198
+ protected
199
+
200
+ # source://async//lib/async/condition.rb#53
201
+ def exchange; end
202
+ end
203
+
204
+ # A load balancing mechanism that can be used process work when the system is idle.
205
+ #
206
+ # source://async//lib/async/idler.rb#8
207
+ class Async::Idler
208
+ # Create a new idler.
209
+ #
210
+ # @return [Idler] a new instance of Idler
211
+ #
212
+ # source://async//lib/async/idler.rb#16
213
+ def initialize(maximum_load = T.unsafe(nil), backoff: T.unsafe(nil), parent: T.unsafe(nil)); end
214
+
215
+ # Wait until the system is idle, then execute the given block in a new task.
216
+ #
217
+ # source://async//lib/async/idler.rb#33
218
+ def async(*arguments, parent: T.unsafe(nil), **options, &block); end
219
+
220
+ # Wait until the system is idle, according to the maximum load specified.
221
+ #
222
+ # If the scheduler is overloaded, this method will sleep for an exponentially increasing amount of time.
223
+ #
224
+ # source://async//lib/async/idler.rb#43
225
+ def wait; end
226
+ end
227
+
228
+ # A thread-safe queue which limits the number of items that can be enqueued.
229
+ #
230
+ # source://async//lib/async/queue.rb#129
231
+ class Async::LimitedQueue < ::Async::Queue
232
+ # Create a new limited queue.
233
+ #
234
+ # @return [LimitedQueue] a new instance of LimitedQueue
235
+ #
236
+ # source://async//lib/async/queue.rb#141
237
+ def initialize(limit = T.unsafe(nil), **options); end
238
+
239
+ # source://async//lib/async/queue.rb#146
240
+ def limit; end
241
+
242
+ # @return [Boolean]
243
+ #
244
+ # source://async//lib/async/queue.rb#151
245
+ def limited?; end
246
+
247
+ class << self
248
+ # @private This exists purely for emitting a warning.
249
+ #
250
+ # source://async//lib/async/queue.rb#131
251
+ def new(*_arg0, **_arg1, &_arg2); end
252
+ end
253
+ end
254
+
255
+ # A general doublely linked list. This is used internally by {Async::Barrier} and {Async::Condition} to manage child tasks.
256
+ #
257
+ # source://async//lib/async/list.rb#9
258
+ class Async::List
259
+ # Initialize a new, empty, list.
260
+ #
261
+ # @return [List] a new instance of List
262
+ #
263
+ # source://async//lib/async/list.rb#11
264
+ def initialize; end
265
+
266
+ # A callback that is invoked when an item is added to the list.
267
+ #
268
+ # source://async//lib/async/list.rb#51
269
+ def added(node); end
270
+
271
+ # Append a node to the end of the list.
272
+ #
273
+ # source://async//lib/async/list.rb#57
274
+ def append(node); end
275
+
276
+ # 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.
277
+ #
278
+ # source://async//lib/async/list.rb#177
279
+ def each(&block); end
280
+
281
+ # @return [Boolean]
282
+ #
283
+ # source://async//lib/async/list.rb#140
284
+ def empty?; end
285
+
286
+ # source://async//lib/async/list.rb#198
287
+ def first; end
288
+
289
+ # Returns the value of attribute head.
290
+ #
291
+ # source://async//lib/async/list.rb#42
292
+ def head; end
293
+
294
+ # Sets the attribute head
295
+ #
296
+ # @param value the value to set the attribute head to.
297
+ #
298
+ # source://async//lib/async/list.rb#42
299
+ def head=(_arg0); end
300
+
301
+ # Determine whether the given node is included in the list.
302
+ #
303
+ # @return [Boolean]
304
+ #
305
+ # source://async//lib/async/list.rb#189
306
+ def include?(needle); end
307
+
308
+ # source://async//lib/async/list.rb#18
309
+ def inspect; end
310
+
311
+ # source://async//lib/async/list.rb#215
312
+ def last; end
313
+
314
+ # Prepend a node to the start of the list.
315
+ #
316
+ # source://async//lib/async/list.rb#71
317
+ def prepend(node); end
318
+
319
+ # Remove the node. If it was already removed, this will raise an error.
320
+ #
321
+ # You should be careful to only remove nodes that are part of this list.
322
+ #
323
+ # source://async//lib/async/list.rb#119
324
+ def remove(node); end
325
+
326
+ # Remove the node if it is in a list.
327
+ #
328
+ # You should be careful to only remove nodes that are part of this list.
329
+ #
330
+ # @return [Boolean]
331
+ #
332
+ # source://async//lib/async/list.rb#105
333
+ def remove?(node); end
334
+
335
+ # A callback that is invoked when an item is removed from the list.
336
+ #
337
+ # source://async//lib/async/list.rb#95
338
+ def removed(node); end
339
+
340
+ # Shift the first node off the list, if it is not empty.
341
+ #
342
+ # source://async//lib/async/list.rb#232
343
+ def shift; end
344
+
345
+ # Returns the value of attribute size.
346
+ #
347
+ # source://async//lib/async/list.rb#48
348
+ def size; end
349
+
350
+ # Add the node, yield, and the remove the node.
351
+ #
352
+ # source://async//lib/async/list.rb#87
353
+ def stack(node, &block); end
354
+
355
+ # Returns the value of attribute tail.
356
+ #
357
+ # source://async//lib/async/list.rb#45
358
+ def tail; end
359
+
360
+ # Sets the attribute tail
361
+ #
362
+ # @param value the value to set the attribute tail to.
363
+ #
364
+ # source://async//lib/async/list.rb#45
365
+ def tail=(_arg0); end
366
+
367
+ # Fast, safe, unbounded accumulation of children.
368
+ #
369
+ # source://async//lib/async/list.rb#26
370
+ def to_a; end
371
+
372
+ # source://async//lib/async/list.rb#18
373
+ def to_s; end
374
+
375
+ private
376
+
377
+ # source://async//lib/async/list.rb#128
378
+ def remove!(node); end
379
+ end
380
+
381
+ # source://async//lib/async/list.rb#252
382
+ class Async::List::Iterator < ::Async::List::Node
383
+ # @return [Iterator] a new instance of Iterator
384
+ #
385
+ # source://async//lib/async/list.rb#253
386
+ def initialize(list); end
387
+
388
+ # source://async//lib/async/list.rb#296
389
+ def each; end
390
+
391
+ # source://async//lib/async/list.rb#281
392
+ def move_current; end
393
+
394
+ # source://async//lib/async/list.rb#271
395
+ def move_next; end
396
+
397
+ # source://async//lib/async/list.rb#263
398
+ def remove!; end
399
+
400
+ class << self
401
+ # source://async//lib/async/list.rb#306
402
+ def each(list, &block); end
403
+ end
404
+ end
405
+
406
+ # A linked list Node.
407
+ #
408
+ # source://async//lib/async/list.rb#239
409
+ class Async::List::Node
410
+ # Returns the value of attribute head.
411
+ #
412
+ # source://async//lib/async/list.rb#240
413
+ def head; end
414
+
415
+ # Sets the attribute head
416
+ #
417
+ # @param value the value to set the attribute head to.
418
+ #
419
+ # source://async//lib/async/list.rb#240
420
+ def head=(_arg0); end
421
+
422
+ # source://async//lib/async/list.rb#244
423
+ def inspect; end
424
+
425
+ # Returns the value of attribute tail.
426
+ #
427
+ # source://async//lib/async/list.rb#241
428
+ def tail; end
429
+
430
+ # Sets the attribute tail
431
+ #
432
+ # @param value the value to set the attribute tail to.
433
+ #
434
+ # source://async//lib/async/list.rb#241
435
+ def tail=(_arg0); end
436
+
437
+ # source://async//lib/async/list.rb#244
438
+ def to_s; end
439
+ end
440
+
441
+ # A node in a tree, used for implementing the task hierarchy.
442
+ #
443
+ # source://async//lib/async/node.rb#71
444
+ class Async::Node
445
+ # Create a new node in the tree.
446
+ #
447
+ # @return [Node] a new instance of Node
448
+ #
449
+ # source://async//lib/async/node.rb#74
450
+ def initialize(parent = T.unsafe(nil), annotation: T.unsafe(nil), transient: T.unsafe(nil)); end
451
+
452
+ # Annotate the node with a description.
453
+ #
454
+ # source://async//lib/async/node.rb#143
455
+ def annotate(annotation); end
456
+
457
+ # Returns the value of attribute annotation.
458
+ #
459
+ # source://async//lib/async/node.rb#109
460
+ def annotation; end
461
+
462
+ # Provides a backtrace for nodes that have an active execution context.
463
+ #
464
+ # source://async//lib/async/node.rb#175
465
+ def backtrace(*arguments); end
466
+
467
+ # Returns the value of attribute children.
468
+ #
469
+ # source://async//lib/async/node.rb#106
470
+ def children; end
471
+
472
+ # Whether this node has any children.
473
+ #
474
+ # @return [Boolean]
475
+ #
476
+ # source://async//lib/async/node.rb#113
477
+ def children?; end
478
+
479
+ # If the node has a parent, and is {finished?}, then remove this node from
480
+ # the parent.
481
+ #
482
+ # source://async//lib/async/node.rb#230
483
+ def consume; end
484
+
485
+ # A description of the node, including the annotation and object name.
486
+ #
487
+ # source://async//lib/async/node.rb#160
488
+ def description; end
489
+
490
+ # Whether the node can be consumed (deleted) safely. By default, checks if the children set is empty.
491
+ #
492
+ # @return [Boolean]
493
+ #
494
+ # source://async//lib/async/node.rb#224
495
+ def finished?; end
496
+
497
+ # @private
498
+ #
499
+ # source://async//lib/async/node.rb#97
500
+ def head; end
501
+
502
+ # @private
503
+ #
504
+ # source://async//lib/async/node.rb#97
505
+ def head=(_arg0); end
506
+
507
+ # source://async//lib/async/node.rb#180
508
+ def inspect; end
509
+
510
+ # Returns the value of attribute parent.
511
+ #
512
+ # source://async//lib/async/node.rb#103
513
+ def parent; end
514
+
515
+ # Change the parent of this node.
516
+ #
517
+ # source://async//lib/async/node.rb#191
518
+ def parent=(parent); end
519
+
520
+ # Print the hierarchy of the task tree from the given node.
521
+ #
522
+ # source://async//lib/async/node.rb#306
523
+ def print_hierarchy(out = T.unsafe(nil), backtrace: T.unsafe(nil)); end
524
+
525
+ # source://async//lib/async/node.rb#92
526
+ def root; end
527
+
528
+ # Attempt to stop the current node immediately, including all non-transient children. Invokes {#stop_children} to stop all children.
529
+ #
530
+ # source://async//lib/async/node.rb#285
531
+ def stop(later = T.unsafe(nil)); end
532
+
533
+ # Whether the node has been stopped.
534
+ #
535
+ # @return [Boolean]
536
+ #
537
+ # source://async//lib/async/node.rb#298
538
+ def stopped?; end
539
+
540
+ # @private
541
+ #
542
+ # source://async//lib/async/node.rb#100
543
+ def tail; end
544
+
545
+ # @private
546
+ #
547
+ # source://async//lib/async/node.rb#100
548
+ def tail=(_arg0); end
549
+
550
+ # 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.
551
+ #
552
+ # source://async//lib/async/node.rb#270
553
+ def terminate; end
554
+
555
+ # source://async//lib/async/node.rb#180
556
+ def to_s; end
557
+
558
+ # Change the transient state of the node.
559
+ #
560
+ # A transient node is not considered when determining if a node is finished, and propagates up if the parent is consumed.
561
+ #
562
+ # source://async//lib/async/node.rb#132
563
+ def transient=(value); end
564
+
565
+ # Represents whether a node is transient. Transient nodes are not considered
566
+ # when determining if a node is finished. This is useful for tasks which are
567
+ # internal to an object rather than explicit user concurrency. For example,
568
+ # a child task which is pruning a connection pool is transient, because it
569
+ # is not directly related to the parent task, and should not prevent the
570
+ # parent task from finishing.
571
+ #
572
+ # @return [Boolean]
573
+ #
574
+ # source://async//lib/async/node.rb#123
575
+ def transient?; end
576
+
577
+ # Traverse the task tree.
578
+ #
579
+ # source://async//lib/async/node.rb#255
580
+ def traverse(&block); end
581
+
582
+ protected
583
+
584
+ # source://async//lib/async/node.rb#210
585
+ def add_child(child); end
586
+
587
+ # source://async//lib/async/node.rb#216
588
+ def remove_child(child); end
589
+
590
+ # source://async//lib/async/node.rb#206
591
+ def set_parent(parent); end
592
+
593
+ # @yield [_self, level]
594
+ # @yieldparam _self [Async::Node] the object that the method was called on
595
+ #
596
+ # source://async//lib/async/node.rb#261
597
+ def traverse_recurse(level = T.unsafe(nil), &block); end
598
+
599
+ private
600
+
601
+ # source://async//lib/async/node.rb#318
602
+ def print_backtrace(out, indent, node); end
603
+
604
+ # Attempt to stop all non-transient children.
605
+ #
606
+ # source://async//lib/async/node.rb#291
607
+ def stop_children(later = T.unsafe(nil)); end
608
+ end
609
+
610
+ # 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.
611
+ #
612
+ # source://async//lib/async/notification.rb#11
613
+ class Async::Notification < ::Async::Condition
614
+ # Signal to a given task that it should resume operations.
615
+ #
616
+ # source://async//lib/async/notification.rb#15
617
+ def signal(value = T.unsafe(nil)); end
618
+ end
619
+
620
+ # source://async//lib/async/notification.rb#23
621
+ class Async::Notification::Signal < ::Struct
622
+ # @return [Boolean]
623
+ #
624
+ # source://async//lib/async/notification.rb#24
625
+ def alive?; end
626
+
627
+ # Returns the value of attribute ready
628
+ #
629
+ # @return [Object] the current value of ready
630
+ def ready; end
631
+
632
+ # Sets the attribute ready
633
+ #
634
+ # @param value [Object] the value to set the attribute ready to.
635
+ # @return [Object] the newly set value
636
+ def ready=(_); end
637
+
638
+ # source://async//lib/async/notification.rb#28
639
+ def transfer; end
640
+
641
+ # Returns the value of attribute value
642
+ #
643
+ # @return [Object] the current value of value
644
+ def value; end
645
+
646
+ # Sets the attribute value
647
+ #
648
+ # @param value [Object] the value to set the attribute value to.
649
+ # @return [Object] the newly set value
650
+ def value=(_); end
651
+
652
+ class << self
653
+ def [](*_arg0); end
654
+ def inspect; end
655
+ def keyword_init?; end
656
+ def members; end
657
+ def new(*_arg0); end
658
+ end
659
+ end
660
+
661
+ # source://async//lib/async/scheduler.rb#24
662
+ Async::Profiler = T.let(T.unsafe(nil), T.untyped)
663
+
664
+ # A promise represents a value that will be available in the future.
665
+ # Unlike Condition, once resolved (or rejected), all future waits return immediately
666
+ # with the stored value or raise the stored exception.
667
+ #
668
+ # This is thread-safe and integrates with the fiber scheduler.
669
+ #
670
+ # source://async//lib/async/promise.rb#15
671
+ class Async::Promise
672
+ # Create a new promise.
673
+ #
674
+ # @return [Promise] a new instance of Promise
675
+ #
676
+ # source://async//lib/async/promise.rb#17
677
+ def initialize; end
678
+
679
+ # Cancel the promise, indicating cancellation.
680
+ # All current and future waiters will receive nil.
681
+ # Can only be called on pending promises - no-op if already resolved.
682
+ #
683
+ # source://async//lib/async/promise.rb#150
684
+ def cancel(exception = T.unsafe(nil)); end
685
+
686
+ # @return [Boolean]
687
+ #
688
+ # source://async//lib/async/promise.rb#43
689
+ def cancelled?; end
690
+
691
+ # @return [Boolean]
692
+ #
693
+ # source://async//lib/async/promise.rb#53
694
+ def completed?; end
695
+
696
+ # @return [Boolean]
697
+ #
698
+ # source://async//lib/async/promise.rb#48
699
+ def failed?; end
700
+
701
+ # Resolve the promise with the result of the block.
702
+ # If the block raises an exception, the promise will be rejected.
703
+ # If the promise was already resolved, the block will not be called.
704
+ #
705
+ # source://async//lib/async/promise.rb#170
706
+ def fulfill(&block); end
707
+
708
+ # Reject the promise with an exception.
709
+ # All current and future waiters will receive this exception.
710
+ # Can only be called once - subsequent calls are ignored.
711
+ #
712
+ # source://async//lib/async/promise.rb#129
713
+ def reject(exception); end
714
+
715
+ # Resolve the promise with a value.
716
+ # All current and future waiters will receive this value.
717
+ # Can only be called once - subsequent calls are ignored.
718
+ #
719
+ # source://async//lib/async/promise.rb#110
720
+ def resolve(value); end
721
+
722
+ # @private For internal use by Task.
723
+ #
724
+ # source://async//lib/async/promise.rb#38
725
+ def resolved; end
726
+
727
+ # @return [Boolean]
728
+ #
729
+ # source://async//lib/async/promise.rb#32
730
+ def resolved?; end
731
+
732
+ # Artificially mark that someone is waiting (useful for suppressing warnings).
733
+ #
734
+ # @private Internal use only.
735
+ #
736
+ # source://async//lib/async/promise.rb#64
737
+ def suppress_warnings!; end
738
+
739
+ # Non-blocking access to the current value. Returns nil if not yet resolved.
740
+ # Does not raise exceptions even if the promise was rejected or cancelled.
741
+ # For resolved promises, returns the raw stored value (result, exception, or cancel exception).
742
+ #
743
+ # source://async//lib/async/promise.rb#73
744
+ def value; end
745
+
746
+ # Wait for the promise to be resolved and return the value.
747
+ # If already resolved, returns immediately. If rejected, raises the stored exception.
748
+ #
749
+ # source://async//lib/async/promise.rb#82
750
+ def wait; end
751
+
752
+ # @return [Boolean]
753
+ #
754
+ # source://async//lib/async/promise.rb#58
755
+ def waiting?; end
756
+
757
+ class << self
758
+ # If a promise is given, fulfill it with the result of the block.
759
+ # If no promise is given, simply yield to the block.
760
+ # This is useful for methods that may optionally take a promise to fulfill.
761
+ #
762
+ # source://async//lib/async/promise.rb#194
763
+ def fulfill(promise, &block); end
764
+ end
765
+ end
766
+
767
+ # Exception used to indicate cancellation.
768
+ #
769
+ # source://async//lib/async/promise.rb#144
770
+ class Async::Promise::Cancel < ::Exception; end
771
+
772
+ # A thread-safe queue which allows items to be processed in order.
773
+ #
774
+ # This implementation uses Thread::Queue internally for thread safety while
775
+ # maintaining compatibility with the fiber scheduler.
776
+ #
777
+ # It has a compatible interface with {Notification} and {Condition}, except that it's multi-value.
778
+ #
779
+ # source://async//lib/async/queue.rb#22
780
+ class Async::Queue
781
+ # Create a new thread-safe queue.
782
+ #
783
+ # @return [Queue] a new instance of Queue
784
+ #
785
+ # source://async//lib/async/queue.rb#31
786
+ def initialize(parent: T.unsafe(nil), delegate: T.unsafe(nil)); end
787
+
788
+ # Compatibility with {::Queue#push}.
789
+ #
790
+ # source://async//lib/async/queue.rb#69
791
+ def <<(item); end
792
+
793
+ # Process each item in the queue.
794
+ #
795
+ # source://async//lib/async/queue.rb#102
796
+ def async(parent: T.unsafe(nil), **options, &block); end
797
+
798
+ # Close the queue, causing all waiting tasks to return `nil`. Any subsequent calls to {enqueue} will raise an exception.
799
+ #
800
+ # source://async//lib/async/queue.rb#42
801
+ def close; end
802
+
803
+ # @return [Boolean]
804
+ #
805
+ # source://async//lib/async/queue.rb#37
806
+ def closed?; end
807
+
808
+ # Remove and return the next item from the queue.
809
+ #
810
+ # source://async//lib/async/queue.rb#83
811
+ def dequeue(timeout: T.unsafe(nil)); end
812
+
813
+ # Enumerate each item in the queue.
814
+ #
815
+ # source://async//lib/async/queue.rb#109
816
+ def each; end
817
+
818
+ # @return [Boolean]
819
+ #
820
+ # source://async//lib/async/queue.rb#52
821
+ def empty?; end
822
+
823
+ # Add multiple items to the queue.
824
+ #
825
+ # source://async//lib/async/queue.rb#74
826
+ def enqueue(*items); end
827
+
828
+ # Compatibility with {::Queue#pop}.
829
+ #
830
+ # source://async//lib/async/queue.rb#90
831
+ def pop(timeout: T.unsafe(nil)); end
832
+
833
+ # Add an item to the queue.
834
+ #
835
+ # source://async//lib/async/queue.rb#62
836
+ def push(item); end
837
+
838
+ # Signal the queue with a value, the same as {#enqueue}.
839
+ #
840
+ # source://async//lib/async/queue.rb#116
841
+ def signal(value = T.unsafe(nil)); end
842
+
843
+ # source://async//lib/async/queue.rb#47
844
+ def size; end
845
+
846
+ # Wait for an item to be available, the same as {#dequeue}.
847
+ #
848
+ # source://async//lib/async/queue.rb#121
849
+ def wait; end
850
+
851
+ # source://async//lib/async/queue.rb#57
852
+ def waiting_count; end
853
+ end
854
+
855
+ # An error raised when trying to enqueue items to a closed queue.
856
+ #
857
+ # source://async//lib/async/queue.rb#25
858
+ class Async::Queue::ClosedError < ::RuntimeError; end
859
+
860
+ # A wrapper around the the scheduler which binds it to the current thread automatically.
861
+ #
862
+ # source://async//lib/async/reactor.rb#12
863
+ class Async::Reactor < ::Async::Scheduler
864
+ # Initialize the reactor and assign it to the current Fiber scheduler.
865
+ #
866
+ # @return [Reactor] a new instance of Reactor
867
+ #
868
+ # source://async//lib/async/reactor.rb#21
869
+ def initialize(*_arg0, **_arg1, &_arg2); end
870
+
871
+ # Close the reactor and remove it from the current Fiber scheduler.
872
+ #
873
+ # source://async//lib/async/reactor.rb#28
874
+ def scheduler_close; end
875
+
876
+ def sleep(*_arg0); end
877
+
878
+ class << self
879
+ # @deprecated Replaced by {Kernel::Async}.
880
+ #
881
+ # source://async//lib/async/reactor.rb#14
882
+ def run(*_arg0, **_arg1, &_arg2); end
883
+ end
884
+ end
885
+
886
+ # Handles scheduling of fibers. Implements the fiber scheduler interface.
887
+ #
888
+ # source://async//lib/async/scheduler.rb#28
889
+ class Async::Scheduler < ::Async::Node
890
+ # Create a new scheduler.
891
+ #
892
+ # @return [Scheduler] a new instance of Scheduler
893
+ #
894
+ # source://async//lib/async/scheduler.rb#76
895
+ def initialize(parent = T.unsafe(nil), selector: T.unsafe(nil), profiler: T.unsafe(nil), worker_pool: T.unsafe(nil)); end
896
+
897
+ # Resolve the address of the given hostname.
898
+ #
899
+ # source://async//lib/async/scheduler.rb#291
900
+ def address_resolve(hostname); end
901
+
902
+ # 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.
903
+ #
904
+ # @deprecated Use {#run} or {Task#async} instead.
905
+ #
906
+ # source://async//lib/async/scheduler.rb#585
907
+ def async(*arguments, **options, &block); end
908
+
909
+ # 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.
910
+ #
911
+ # source://async//lib/async/scheduler.rb#230
912
+ def block(blocker, timeout); end
913
+
914
+ # Terminate all child tasks and close the scheduler.
915
+ #
916
+ # source://async//lib/async/scheduler.rb#148
917
+ def close; end
918
+
919
+ # @return [Boolean]
920
+ #
921
+ # source://async//lib/async/scheduler.rb#173
922
+ def closed?; end
923
+
924
+ # Create a new fiber and return it without starting execution.
925
+ #
926
+ # source://async//lib/async/scheduler.rb#600
927
+ def fiber(*_arg0, **_arg1, &_arg2); end
928
+
929
+ # Raise an exception on the specified fiber, waking up the event loop if necessary.
930
+ #
931
+ # source://async//lib/async/scheduler.rb#399
932
+ def fiber_interrupt(fiber, exception); end
933
+
934
+ # Interrupt the event loop and cause it to exit.
935
+ #
936
+ # source://async//lib/async/scheduler.rb#184
937
+ def interrupt; end
938
+
939
+ # Read from the specified IO into the buffer.
940
+ #
941
+ # source://async//lib/async/scheduler.rb#336
942
+ def io_read(io, buffer, length, offset = T.unsafe(nil)); end
943
+
944
+ # Wait for the specified IOs to become ready for the specified events.
945
+ #
946
+ # source://async//lib/async/scheduler.rb#421
947
+ def io_select(*_arg0, **_arg1, &_arg2); end
948
+
949
+ # Wait for the specified IO to become ready for the specified events.
950
+ #
951
+ # source://async//lib/async/scheduler.rb#306
952
+ def io_wait(io, events, timeout = T.unsafe(nil)); end
953
+
954
+ # Write the specified buffer to the IO.
955
+ #
956
+ # source://async//lib/async/scheduler.rb#360
957
+ def io_write(io, buffer, length, offset = T.unsafe(nil)); end
958
+
959
+ # Sleep for the specified duration.
960
+ #
961
+ # source://async//lib/async/scheduler.rb#275
962
+ def kernel_sleep(duration = T.unsafe(nil)); end
963
+
964
+ # Compute the scheduler load according to the busy and idle times that are updated by the run loop.
965
+ #
966
+ # source://async//lib/async/scheduler.rb#105
967
+ def load; end
968
+
969
+ # Wait for the specified process ID to exit.
970
+ #
971
+ # source://async//lib/async/scheduler.rb#413
972
+ def process_wait(pid, flags); end
973
+
974
+ # Schedule a fiber (or equivalent object) to be resumed on the next loop through the reactor.
975
+ #
976
+ # source://async//lib/async/scheduler.rb#201
977
+ def push(fiber); end
978
+
979
+ # Raise an exception on a specified fiber with the given arguments.
980
+ #
981
+ # This internally schedules the current fiber to be ready, before raising the exception, so that it will later resume execution.
982
+ #
983
+ # source://async//lib/async/scheduler.rb#211
984
+ def raise(*_arg0, **_arg1, &_arg2); end
985
+
986
+ # Resume execution of the specified fiber.
987
+ #
988
+ # source://async//lib/async/scheduler.rb#219
989
+ def resume(fiber, *arguments); end
990
+
991
+ # Run the reactor until all tasks are finished. Proxies arguments to {#async} immediately before entering the loop, if a block is provided.
992
+ #
993
+ # Forwards all parameters to {#async} if a block is given.
994
+ #
995
+ # source://async//lib/async/scheduler.rb#559
996
+ def run(*_arg0, **_arg1, &_arg2); end
997
+
998
+ # Run one iteration of the event loop.
999
+ #
1000
+ # source://async//lib/async/scheduler.rb#480
1001
+ def run_once(timeout = T.unsafe(nil)); end
1002
+
1003
+ # Invoked when the fiber scheduler is being closed.
1004
+ #
1005
+ # Executes the run loop until all tasks are finished, then closes the scheduler.
1006
+ #
1007
+ # source://async//lib/async/scheduler.rb#127
1008
+ def scheduler_close(error = T.unsafe(nil)); end
1009
+
1010
+ # Stop all children, including transient children.
1011
+ #
1012
+ # source://async//lib/async/scheduler.rb#514
1013
+ def stop; end
1014
+
1015
+ # Terminate all child tasks.
1016
+ #
1017
+ # source://async//lib/async/scheduler.rb#137
1018
+ def terminate; end
1019
+
1020
+ # 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.
1021
+ #
1022
+ # source://async//lib/async/scheduler.rb#640
1023
+ def timeout_after(duration, exception, message, &block); end
1024
+
1025
+ # source://async//lib/async/scheduler.rb#178
1026
+ def to_s; end
1027
+
1028
+ # Transfer from the calling fiber to the event loop.
1029
+ #
1030
+ # source://async//lib/async/scheduler.rb#190
1031
+ def transfer; end
1032
+
1033
+ # Unblock a fiber that was previously blocked.
1034
+ #
1035
+ # source://async//lib/async/scheduler.rb#259
1036
+ def unblock(blocker, fiber); end
1037
+
1038
+ # 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.
1039
+ #
1040
+ # source://async//lib/async/scheduler.rb#613
1041
+ def with_timeout(duration, exception = T.unsafe(nil), message = T.unsafe(nil), &block); end
1042
+
1043
+ # Yield the current fiber and resume it on the next iteration of the event loop.
1044
+ #
1045
+ # source://async//lib/async/scheduler.rb#195
1046
+ def yield; end
1047
+
1048
+ private
1049
+
1050
+ # Checks and clears the interrupted state of the scheduler.
1051
+ #
1052
+ # @return [Boolean]
1053
+ #
1054
+ # source://async//lib/async/scheduler.rb#498
1055
+ def interrupted?; end
1056
+
1057
+ # source://async//lib/async/scheduler.rb#520
1058
+ def run_loop(&block); end
1059
+
1060
+ # Run one iteration of the event loop.
1061
+ #
1062
+ # 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.
1063
+ #
1064
+ # source://async//lib/async/scheduler.rb#436
1065
+ def run_once!(timeout = T.unsafe(nil)); end
1066
+
1067
+ class << self
1068
+ # Whether the fiber scheduler is supported.
1069
+ #
1070
+ # @return [Boolean]
1071
+ #
1072
+ # source://async//lib/async/scheduler.rb#45
1073
+ def supported?; end
1074
+ end
1075
+ end
1076
+
1077
+ # Used to augment the scheduler to add support for blocking operations.
1078
+ #
1079
+ # source://async//lib/async/scheduler.rb#50
1080
+ module Async::Scheduler::BlockingOperationWait
1081
+ # Wait for the given work to be executed.
1082
+ #
1083
+ # source://async//lib/async/scheduler.rb#58
1084
+ def blocking_operation_wait(work); end
1085
+ end
1086
+
1087
+ # Raised when an operation is attempted on a closed scheduler.
1088
+ #
1089
+ # source://async//lib/async/scheduler.rb#34
1090
+ class Async::Scheduler::ClosedError < ::RuntimeError
1091
+ # Create a new error.
1092
+ #
1093
+ # @return [ClosedError] a new instance of ClosedError
1094
+ #
1095
+ # source://async//lib/async/scheduler.rb#38
1096
+ def initialize(message = T.unsafe(nil)); end
1097
+ end
1098
+
1099
+ # Used to defer stopping the current task until later.
1100
+ #
1101
+ # source://async//lib/async/scheduler.rb#377
1102
+ class Async::Scheduler::FiberInterrupt
1103
+ # Create a new stop later operation.
1104
+ #
1105
+ # @return [FiberInterrupt] a new instance of FiberInterrupt
1106
+ #
1107
+ # source://async//lib/async/scheduler.rb#381
1108
+ def initialize(fiber, exception); end
1109
+
1110
+ # @return [Boolean]
1111
+ #
1112
+ # source://async//lib/async/scheduler.rb#387
1113
+ def alive?; end
1114
+
1115
+ # Transfer control to the operation - this will stop the task.
1116
+ #
1117
+ # source://async//lib/async/scheduler.rb#392
1118
+ def transfer; end
1119
+ end
1120
+
1121
+ # source://async//lib/async/scheduler.rb#29
1122
+ Async::Scheduler::WORKER_POOL = T.let(T.unsafe(nil), T.untyped)
1123
+
1124
+ # source://async//lib/async/scheduler.rb#68
1125
+ Async::Scheduler::WorkerPool = T.let(T.unsafe(nil), T.untyped)
1126
+
1127
+ # A synchronization primitive, which limits access to a given resource.
1128
+ #
1129
+ # source://async//lib/async/semaphore.rb#11
1130
+ class Async::Semaphore
1131
+ # @return [Semaphore] a new instance of Semaphore
1132
+ #
1133
+ # source://async//lib/async/semaphore.rb#14
1134
+ def initialize(limit = T.unsafe(nil), parent: T.unsafe(nil)); end
1135
+
1136
+ # Acquire the semaphore, block if we are at the limit.
1137
+ # If no block is provided, you must call release manually.
1138
+ #
1139
+ # source://async//lib/async/semaphore.rb#79
1140
+ def acquire; end
1141
+
1142
+ # Run an async task. Will wait until the semaphore is ready until spawning and running the task.
1143
+ #
1144
+ # source://async//lib/async/semaphore.rb#61
1145
+ def async(*arguments, parent: T.unsafe(nil), **options); end
1146
+
1147
+ # Whether trying to acquire this semaphore would block.
1148
+ #
1149
+ # @return [Boolean]
1150
+ #
1151
+ # source://async//lib/async/semaphore.rb#56
1152
+ def blocking?; end
1153
+
1154
+ # The current number of tasks that have acquired the semaphore.
1155
+ #
1156
+ # source://async//lib/async/semaphore.rb#23
1157
+ def count; end
1158
+
1159
+ # Is the semaphore currently acquired?
1160
+ #
1161
+ # @return [Boolean]
1162
+ #
1163
+ # source://async//lib/async/semaphore.rb#51
1164
+ def empty?; end
1165
+
1166
+ # The maximum number of tasks that can acquire the semaphore.
1167
+ #
1168
+ # source://async//lib/async/semaphore.rb#26
1169
+ def limit; end
1170
+
1171
+ # 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.
1172
+ #
1173
+ # 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.
1174
+ #
1175
+ # source://async//lib/async/semaphore.rb#36
1176
+ def limit=(limit); end
1177
+
1178
+ # Release the semaphore. Must match up with a corresponding call to `acquire`. Will release waiting fibers in FIFO order.
1179
+ #
1180
+ # source://async//lib/async/semaphore.rb#94
1181
+ def release; end
1182
+
1183
+ # The tasks waiting on this semaphore.
1184
+ #
1185
+ # source://async//lib/async/semaphore.rb#29
1186
+ def waiting; end
1187
+
1188
+ private
1189
+
1190
+ # Wait until the semaphore becomes available.
1191
+ #
1192
+ # source://async//lib/async/semaphore.rb#119
1193
+ def wait; end
1194
+ end
1195
+
1196
+ # source://async//lib/async/semaphore.rb#104
1197
+ class Async::Semaphore::FiberNode < ::Async::List::Node
1198
+ # @return [FiberNode] a new instance of FiberNode
1199
+ #
1200
+ # source://async//lib/async/semaphore.rb#105
1201
+ def initialize(fiber); end
1202
+
1203
+ # source://async//lib/async/semaphore.rb#109
1204
+ def resume; end
1205
+ end
1206
+
1207
+ # Raised when a task is explicitly stopped.
1208
+ #
1209
+ # source://async//lib/async/stop.rb#11
1210
+ class Async::Stop < ::Exception
1211
+ # Create a new stop operation.
1212
+ #
1213
+ # This is a compatibility method for Ruby versions before 3.5 where cause is not propagated correctly when using {Fiber#raise}
1214
+ #
1215
+ # @return [Stop] a new instance of Stop
1216
+ #
1217
+ # source://async//lib/async/stop.rb#43
1218
+ def initialize(message = T.unsafe(nil)); end
1219
+
1220
+ # 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.
1221
+ #
1222
+ # source://async//lib/async/stop.rb#55
1223
+ def cause; end
1224
+ end
1225
+
1226
+ # Represents the source of the stop operation.
1227
+ #
1228
+ # source://async//lib/async/stop.rb#13
1229
+ class Async::Stop::Cause < ::Exception
1230
+ class << self
1231
+ # source://async//lib/async/stop.rb#16
1232
+ def backtrace; end
1233
+
1234
+ # Create a new cause of the stop operation, with the given message.
1235
+ #
1236
+ # source://async//lib/async/stop.rb#30
1237
+ def for(message = T.unsafe(nil)); end
1238
+ end
1239
+ end
1240
+
1241
+ # Used to defer stopping the current task until later.
1242
+ #
1243
+ # source://async//lib/async/stop.rb#61
1244
+ class Async::Stop::Later
1245
+ # Create a new stop later operation.
1246
+ #
1247
+ # @return [Later] a new instance of Later
1248
+ #
1249
+ # source://async//lib/async/stop.rb#66
1250
+ def initialize(task, cause = T.unsafe(nil)); end
1251
+
1252
+ # @return [Boolean]
1253
+ #
1254
+ # source://async//lib/async/stop.rb#72
1255
+ def alive?; end
1256
+
1257
+ # Transfer control to the operation - this will stop the task.
1258
+ #
1259
+ # source://async//lib/async/stop.rb#77
1260
+ def transfer; end
1261
+ end
1262
+
1263
+ # source://async//lib/async/task.rb#35
1264
+ class Async::Task < ::Async::Node
1265
+ # Create a new task.
1266
+ #
1267
+ # @return [Task] a new instance of Task
1268
+ #
1269
+ # source://async//lib/async/task.rb#63
1270
+ def initialize(parent = T.unsafe(nil), finished: T.unsafe(nil), **options, &block); end
1271
+
1272
+ # @return [Boolean]
1273
+ #
1274
+ # source://async//lib/async/task.rb#148
1275
+ def alive?; end
1276
+
1277
+ # Annotate the task with a description.
1278
+ #
1279
+ # This will internally try to annotate the fiber if it is running, otherwise it will annotate the task itself.
1280
+ #
1281
+ # source://async//lib/async/task.rb#105
1282
+ def annotate(annotation, &block); end
1283
+
1284
+ # source://async//lib/async/task.rb#114
1285
+ def annotation; end
1286
+
1287
+ # Run an asynchronous task as a child of the current task.
1288
+ #
1289
+ # @raise [FinishedError]
1290
+ #
1291
+ # source://async//lib/async/task.rb#229
1292
+ def async(*arguments, **options, &block); end
1293
+
1294
+ # source://async//lib/async/task.rb#96
1295
+ def backtrace(*arguments); end
1296
+
1297
+ # Alias for {#completed?}.
1298
+ #
1299
+ # @return [Boolean]
1300
+ #
1301
+ # source://async//lib/async/task.rb#180
1302
+ def complete?; end
1303
+
1304
+ # @return [Boolean]
1305
+ #
1306
+ # source://async//lib/async/task.rb#175
1307
+ def completed?; end
1308
+
1309
+ # @return [Boolean]
1310
+ #
1311
+ # source://async//lib/async/task.rb#389
1312
+ def current?; end
1313
+
1314
+ # Defer the handling of stop. During the execution of the given block, if a stop 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_stop block to ensure that the task is stopped when the response is complete but not before.
1315
+ #
1316
+ # You can nest calls to defer_stop, but the stop will only be deferred until the outermost block exits.
1317
+ #
1318
+ # If stop is invoked a second time, it will be immediately executed.
1319
+ #
1320
+ # source://async//lib/async/task.rb#338
1321
+ def defer_stop; end
1322
+
1323
+ # @return [Boolean]
1324
+ #
1325
+ # source://async//lib/async/task.rb#165
1326
+ def failed?; end
1327
+
1328
+ # Returns the value of attribute fiber.
1329
+ #
1330
+ # source://async//lib/async/task.rb#145
1331
+ def fiber; end
1332
+
1333
+ # Whether we can remove this node from the reactor graph.
1334
+ #
1335
+ # @return [Boolean]
1336
+ #
1337
+ # source://async//lib/async/task.rb#154
1338
+ def finished?; end
1339
+
1340
+ # source://async//lib/async/task.rb#91
1341
+ def reactor; end
1342
+
1343
+ # Access the result of the task without waiting. May be nil if the task is not completed. Does not raise exceptions.
1344
+ #
1345
+ # source://async//lib/async/task.rb#266
1346
+ def result; end
1347
+
1348
+ # Begin the execution of the task.
1349
+ #
1350
+ # source://async//lib/async/task.rb#201
1351
+ def run(*arguments); end
1352
+
1353
+ # @return [Boolean]
1354
+ #
1355
+ # source://async//lib/async/task.rb#160
1356
+ def running?; end
1357
+
1358
+ # @deprecated Prefer {Kernel#sleep} except when compatibility with `stable-v1` is required.
1359
+ #
1360
+ # source://async//lib/async/task.rb#128
1361
+ def sleep(duration = T.unsafe(nil)); end
1362
+
1363
+ # source://async//lib/async/task.rb#185
1364
+ def status; end
1365
+
1366
+ # Stop the task and all of its children.
1367
+ #
1368
+ # If `later` is false, it means that `stop` has been invoked directly. When `later` is true, it means that `stop` is invoked by `stop_children` or some other indirect mechanism. In that case, if we encounter the "current" fiber, we can't stop it right away, as it's currently performing `#stop`. Stopping it immediately would interrupt the current stop traversal, so we need to schedule the stop to occur later.
1369
+ #
1370
+ # source://async//lib/async/task.rb#282
1371
+ def stop(later = T.unsafe(nil), cause: T.unsafe(nil)); end
1372
+
1373
+ # @return [Boolean]
1374
+ #
1375
+ # source://async//lib/async/task.rb#371
1376
+ def stop_deferred?; end
1377
+
1378
+ # @return [Boolean]
1379
+ #
1380
+ # source://async//lib/async/task.rb#170
1381
+ def stopped?; end
1382
+
1383
+ # source://async//lib/async/task.rb#123
1384
+ def to_s; end
1385
+
1386
+ # 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 stopped, this will return `nil`.
1387
+ #
1388
+ # 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).
1389
+ #
1390
+ # source://async//lib/async/task.rb#253
1391
+ def wait; end
1392
+
1393
+ # Execute the given block of code, raising the specified exception if it exceeds the given duration during a non-blocking operation.
1394
+ #
1395
+ # source://async//lib/async/task.rb#135
1396
+ def with_timeout(duration, exception = T.unsafe(nil), message = T.unsafe(nil), &block); end
1397
+
1398
+ # Yield back to the reactor and allow other fibers to execute.
1399
+ #
1400
+ # source://async//lib/async/task.rb#140
1401
+ def yield; end
1402
+
1403
+ private
1404
+
1405
+ # State transition into the completed state.
1406
+ #
1407
+ # source://async//lib/async/task.rb#410
1408
+ def completed!(result); end
1409
+
1410
+ # State transition into the failed state.
1411
+ #
1412
+ # source://async//lib/async/task.rb#416
1413
+ def failed!(exception = T.unsafe(nil)); end
1414
+
1415
+ # Finish the current task, moving any children to the parent.
1416
+ #
1417
+ # source://async//lib/async/task.rb#400
1418
+ def finish!; end
1419
+
1420
+ # source://async//lib/async/task.rb#449
1421
+ def schedule(&block); end
1422
+
1423
+ # source://async//lib/async/task.rb#443
1424
+ def stop!; end
1425
+
1426
+ # source://async//lib/async/task.rb#421
1427
+ def stopped!; end
1428
+
1429
+ # source://async//lib/async/task.rb#395
1430
+ def warn(*_arg0, **_arg1, &_arg2); end
1431
+
1432
+ class << self
1433
+ # Lookup the {Task} for the current fiber. Raise `RuntimeError` if none is available.
1434
+ # @raises[RuntimeError] If task was not {set!} for the current fiber.
1435
+ #
1436
+ # source://async//lib/async/task.rb#378
1437
+ def current; end
1438
+
1439
+ # Check if there is a task defined for the current fiber.
1440
+ #
1441
+ # @return [Boolean]
1442
+ #
1443
+ # source://async//lib/async/task.rb#384
1444
+ def current?; end
1445
+
1446
+ # Run the given block of code in a task, asynchronously, in the given scheduler.
1447
+ #
1448
+ # source://async//lib/async/task.rb#54
1449
+ def run(scheduler, *arguments, **options, &block); end
1450
+
1451
+ # @deprecated With no replacement.
1452
+ #
1453
+ # source://async//lib/async/task.rb#47
1454
+ def yield; end
1455
+ end
1456
+ end
1457
+
1458
+ # Raised when a child task is created within a task that has finished execution.
1459
+ #
1460
+ # source://async//lib/async/task.rb#37
1461
+ class Async::Task::FinishedError < ::RuntimeError
1462
+ # Create a new finished error.
1463
+ #
1464
+ # @return [FinishedError] a new instance of FinishedError
1465
+ #
1466
+ # source://async//lib/async/task.rb#41
1467
+ def initialize(message = T.unsafe(nil)); end
1468
+ end
1469
+
1470
+ # Represents a flexible timeout that can be rescheduled or extended.
1471
+ #
1472
+ # source://async//lib/async/timeout.rb#9
1473
+ class Async::Timeout
1474
+ # Initialize a new timeout.
1475
+ #
1476
+ # @return [Timeout] a new instance of Timeout
1477
+ #
1478
+ # source://async//lib/async/timeout.rb#11
1479
+ def initialize(timers, handle); end
1480
+
1481
+ # Adjust the timeout by the specified duration.
1482
+ #
1483
+ # The duration is relative to the timeout time, e.g. adjusting the timeout by 5 increases the current duration by 5 seconds.
1484
+ #
1485
+ # source://async//lib/async/timeout.rb#36
1486
+ def adjust(duration); end
1487
+
1488
+ # Cancel the timeout, preventing it from executing.
1489
+ #
1490
+ # source://async//lib/async/timeout.rb#59
1491
+ def cancel!; end
1492
+
1493
+ # @return [Boolean]
1494
+ #
1495
+ # source://async//lib/async/timeout.rb#64
1496
+ def cancelled?; end
1497
+
1498
+ # source://async//lib/async/timeout.rb#17
1499
+ def duration; end
1500
+
1501
+ # Update the duration of the timeout.
1502
+ #
1503
+ # 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.
1504
+ #
1505
+ # source://async//lib/async/timeout.rb#26
1506
+ def duration=(value); end
1507
+
1508
+ # source://async//lib/async/timeout.rb#54
1509
+ def now; end
1510
+
1511
+ # source://async//lib/async/timeout.rb#41
1512
+ def time; end
1513
+
1514
+ # Assign a new time to the timeout, rescheduling it if necessary.
1515
+ #
1516
+ # source://async//lib/async/timeout.rb#49
1517
+ def time=(value); end
1518
+
1519
+ private
1520
+
1521
+ # Reschedule the timeout to occur at the specified time.
1522
+ #
1523
+ # source://async//lib/async/timeout.rb#76
1524
+ def reschedule(time); end
1525
+ end
1526
+
1527
+ # Raised when attempting to reschedule a cancelled timeout.
1528
+ #
1529
+ # source://async//lib/async/timeout.rb#69
1530
+ class Async::Timeout::CancelledError < ::RuntimeError; end
1531
+
1532
+ # Raised if a timeout occurs on a specific Fiber. Handled gracefully by `Task`.
1533
+ #
1534
+ # source://async//lib/async/task.rb#25
1535
+ class Async::TimeoutError < ::StandardError
1536
+ # Create a new timeout error.
1537
+ #
1538
+ # @return [TimeoutError] a new instance of TimeoutError
1539
+ #
1540
+ # source://async//lib/async/task.rb#29
1541
+ def initialize(message = T.unsafe(nil)); end
1542
+ end
1543
+
1544
+ # source://async//lib/async/version.rb#7
1545
+ Async::VERSION = T.let(T.unsafe(nil), String)
1546
+
1547
+ # Extensions to all Ruby objects.
1548
+ #
1549
+ # source://async//lib/kernel/async.rb#8
1550
+ module Kernel
1551
+ # Run the given block of code in a task, asynchronously, creating a reactor if necessary.
1552
+ #
1553
+ # The preferred method to invoke asynchronous behavior at the top level.
1554
+ #
1555
+ # - When invoked within an existing reactor task, it will run the given block
1556
+ # asynchronously. Will return the task once it has been scheduled.
1557
+ # - When invoked at the top level, will create and run a reactor, and invoke
1558
+ # the block as an asynchronous task. Will block until the reactor finishes
1559
+ # running.
1560
+ #
1561
+ # source://async//lib/kernel/async.rb#24
1562
+ def Async(*_arg0, **_arg1, &_arg2); end
1563
+
1564
+ # Create a barrier, yield it to the block, and then wait for all tasks to complete.
1565
+ #
1566
+ # If no scheduler is running, one will be created automatically for the duration of the block.
1567
+ #
1568
+ # 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.
1569
+ #
1570
+ # source://async//lib/kernel/barrier.rb#20
1571
+ def Barrier(parent: T.unsafe(nil), **options); end
1572
+
1573
+ # Run the given block of code synchronously, but within a reactor if not already in one.
1574
+ #
1575
+ # source://async//lib/kernel/sync.rb#20
1576
+ def Sync(annotation: T.unsafe(nil), &block); end
1577
+ end