rbs-relaxed 3.9.0.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 (484) hide show
  1. checksums.yaml +7 -0
  2. data/.github/dependabot.yml +22 -0
  3. data/.github/workflows/comments.yml +35 -0
  4. data/.github/workflows/dependabot.yml +30 -0
  5. data/.github/workflows/ruby.yml +82 -0
  6. data/.github/workflows/typecheck.yml +38 -0
  7. data/.github/workflows/windows.yml +43 -0
  8. data/.gitignore +23 -0
  9. data/.rubocop.yml +68 -0
  10. data/BSDL +22 -0
  11. data/CHANGELOG.md +1868 -0
  12. data/COPYING +56 -0
  13. data/README.md +203 -0
  14. data/Rakefile +417 -0
  15. data/Steepfile +44 -0
  16. data/config.yml +313 -0
  17. data/core/array.rbs +4062 -0
  18. data/core/basic_object.rbs +375 -0
  19. data/core/binding.rbs +150 -0
  20. data/core/builtin.rbs +277 -0
  21. data/core/class.rbs +220 -0
  22. data/core/comparable.rbs +171 -0
  23. data/core/complex.rbs +786 -0
  24. data/core/constants.rbs +96 -0
  25. data/core/data.rbs +415 -0
  26. data/core/dir.rbs +981 -0
  27. data/core/encoding.rbs +1371 -0
  28. data/core/enumerable.rbs +2405 -0
  29. data/core/enumerator/product.rbs +92 -0
  30. data/core/enumerator.rbs +630 -0
  31. data/core/env.rbs +6 -0
  32. data/core/errno.rbs +673 -0
  33. data/core/errors.rbs +760 -0
  34. data/core/exception.rbs +485 -0
  35. data/core/false_class.rbs +82 -0
  36. data/core/fiber.rbs +550 -0
  37. data/core/fiber_error.rbs +11 -0
  38. data/core/file.rbs +2936 -0
  39. data/core/file_test.rbs +331 -0
  40. data/core/float.rbs +1151 -0
  41. data/core/gc.rbs +644 -0
  42. data/core/global_variables.rbs +184 -0
  43. data/core/hash.rbs +1861 -0
  44. data/core/integer.rbs +1413 -0
  45. data/core/io/buffer.rbs +984 -0
  46. data/core/io/wait.rbs +70 -0
  47. data/core/io.rbs +3406 -0
  48. data/core/kernel.rbs +3096 -0
  49. data/core/marshal.rbs +207 -0
  50. data/core/match_data.rbs +635 -0
  51. data/core/math.rbs +729 -0
  52. data/core/method.rbs +386 -0
  53. data/core/module.rbs +1704 -0
  54. data/core/nil_class.rbs +209 -0
  55. data/core/numeric.rbs +818 -0
  56. data/core/object.rbs +110 -0
  57. data/core/object_space/weak_key_map.rbs +166 -0
  58. data/core/object_space.rbs +190 -0
  59. data/core/proc.rbs +868 -0
  60. data/core/process.rbs +2296 -0
  61. data/core/ractor.rbs +1068 -0
  62. data/core/random.rbs +237 -0
  63. data/core/range.rbs +1107 -0
  64. data/core/rational.rbs +531 -0
  65. data/core/rb_config.rbs +88 -0
  66. data/core/rbs/unnamed/argf.rbs +1229 -0
  67. data/core/rbs/unnamed/env_class.rbs +1209 -0
  68. data/core/rbs/unnamed/random.rbs +293 -0
  69. data/core/refinement.rbs +59 -0
  70. data/core/regexp.rbs +1930 -0
  71. data/core/ruby_vm.rbs +765 -0
  72. data/core/rubygems/basic_specification.rbs +6 -0
  73. data/core/rubygems/config_file.rbs +38 -0
  74. data/core/rubygems/dependency_installer.rbs +6 -0
  75. data/core/rubygems/errors.rbs +176 -0
  76. data/core/rubygems/installer.rbs +15 -0
  77. data/core/rubygems/path_support.rbs +6 -0
  78. data/core/rubygems/platform.rbs +7 -0
  79. data/core/rubygems/request_set.rbs +49 -0
  80. data/core/rubygems/requirement.rbs +148 -0
  81. data/core/rubygems/rubygems.rbs +1171 -0
  82. data/core/rubygems/source_list.rbs +15 -0
  83. data/core/rubygems/specification.rbs +23 -0
  84. data/core/rubygems/stream_ui.rbs +5 -0
  85. data/core/rubygems/uninstaller.rbs +10 -0
  86. data/core/rubygems/version.rbs +294 -0
  87. data/core/set.rbs +621 -0
  88. data/core/signal.rbs +100 -0
  89. data/core/string.rbs +3583 -0
  90. data/core/struct.rbs +667 -0
  91. data/core/symbol.rbs +475 -0
  92. data/core/thread.rbs +1765 -0
  93. data/core/thread_group.rbs +79 -0
  94. data/core/time.rbs +1762 -0
  95. data/core/trace_point.rbs +477 -0
  96. data/core/true_class.rbs +98 -0
  97. data/core/unbound_method.rbs +329 -0
  98. data/core/warning.rbs +87 -0
  99. data/docs/CONTRIBUTING.md +106 -0
  100. data/docs/architecture.md +110 -0
  101. data/docs/collection.md +192 -0
  102. data/docs/data_and_struct.md +86 -0
  103. data/docs/gem.md +57 -0
  104. data/docs/rbs_by_example.md +309 -0
  105. data/docs/repo.md +125 -0
  106. data/docs/sigs.md +167 -0
  107. data/docs/stdlib.md +147 -0
  108. data/docs/syntax.md +910 -0
  109. data/docs/tools.md +17 -0
  110. data/exe/rbs +7 -0
  111. data/ext/rbs_extension/extconf.rb +15 -0
  112. data/ext/rbs_extension/lexer.c +2728 -0
  113. data/ext/rbs_extension/lexer.h +179 -0
  114. data/ext/rbs_extension/lexer.re +147 -0
  115. data/ext/rbs_extension/lexstate.c +175 -0
  116. data/ext/rbs_extension/location.c +325 -0
  117. data/ext/rbs_extension/location.h +85 -0
  118. data/ext/rbs_extension/main.c +33 -0
  119. data/ext/rbs_extension/parser.c +2973 -0
  120. data/ext/rbs_extension/parser.h +18 -0
  121. data/ext/rbs_extension/parserstate.c +397 -0
  122. data/ext/rbs_extension/parserstate.h +163 -0
  123. data/ext/rbs_extension/rbs_extension.h +31 -0
  124. data/ext/rbs_extension/unescape.c +32 -0
  125. data/goodcheck.yml +91 -0
  126. data/include/rbs/constants.h +82 -0
  127. data/include/rbs/ruby_objs.h +72 -0
  128. data/include/rbs/util/rbs_constant_pool.h +219 -0
  129. data/include/rbs.h +7 -0
  130. data/lib/rbs/ancestor_graph.rb +92 -0
  131. data/lib/rbs/annotate/annotations.rb +199 -0
  132. data/lib/rbs/annotate/formatter.rb +92 -0
  133. data/lib/rbs/annotate/rdoc_annotator.rb +400 -0
  134. data/lib/rbs/annotate/rdoc_source.rb +131 -0
  135. data/lib/rbs/annotate.rb +8 -0
  136. data/lib/rbs/ast/annotation.rb +29 -0
  137. data/lib/rbs/ast/comment.rb +29 -0
  138. data/lib/rbs/ast/declarations.rb +467 -0
  139. data/lib/rbs/ast/directives.rb +49 -0
  140. data/lib/rbs/ast/members.rb +451 -0
  141. data/lib/rbs/ast/type_param.rb +225 -0
  142. data/lib/rbs/ast/visitor.rb +137 -0
  143. data/lib/rbs/buffer.rb +67 -0
  144. data/lib/rbs/builtin_names.rb +58 -0
  145. data/lib/rbs/cli/colored_io.rb +48 -0
  146. data/lib/rbs/cli/diff.rb +83 -0
  147. data/lib/rbs/cli/validate.rb +357 -0
  148. data/lib/rbs/cli.rb +1223 -0
  149. data/lib/rbs/collection/cleaner.rb +38 -0
  150. data/lib/rbs/collection/config/lockfile.rb +92 -0
  151. data/lib/rbs/collection/config/lockfile_generator.rb +218 -0
  152. data/lib/rbs/collection/config.rb +81 -0
  153. data/lib/rbs/collection/installer.rb +32 -0
  154. data/lib/rbs/collection/sources/base.rb +14 -0
  155. data/lib/rbs/collection/sources/git.rb +258 -0
  156. data/lib/rbs/collection/sources/local.rb +81 -0
  157. data/lib/rbs/collection/sources/rubygems.rb +48 -0
  158. data/lib/rbs/collection/sources/stdlib.rb +50 -0
  159. data/lib/rbs/collection/sources.rb +38 -0
  160. data/lib/rbs/collection.rb +16 -0
  161. data/lib/rbs/constant.rb +28 -0
  162. data/lib/rbs/definition.rb +401 -0
  163. data/lib/rbs/definition_builder/ancestor_builder.rb +620 -0
  164. data/lib/rbs/definition_builder/method_builder.rb +254 -0
  165. data/lib/rbs/definition_builder.rb +845 -0
  166. data/lib/rbs/diff.rb +125 -0
  167. data/lib/rbs/environment/use_map.rb +77 -0
  168. data/lib/rbs/environment.rb +829 -0
  169. data/lib/rbs/environment_loader.rb +173 -0
  170. data/lib/rbs/environment_walker.rb +155 -0
  171. data/lib/rbs/errors.rb +645 -0
  172. data/lib/rbs/factory.rb +18 -0
  173. data/lib/rbs/file_finder.rb +28 -0
  174. data/lib/rbs/location_aux.rb +138 -0
  175. data/lib/rbs/locator.rb +243 -0
  176. data/lib/rbs/method_type.rb +143 -0
  177. data/lib/rbs/namespace.rb +125 -0
  178. data/lib/rbs/parser/lex_result.rb +15 -0
  179. data/lib/rbs/parser/token.rb +23 -0
  180. data/lib/rbs/parser_aux.rb +114 -0
  181. data/lib/rbs/prototype/helpers.rb +140 -0
  182. data/lib/rbs/prototype/node_usage.rb +99 -0
  183. data/lib/rbs/prototype/rb.rb +840 -0
  184. data/lib/rbs/prototype/rbi.rb +641 -0
  185. data/lib/rbs/prototype/runtime/helpers.rb +59 -0
  186. data/lib/rbs/prototype/runtime/reflection.rb +19 -0
  187. data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
  188. data/lib/rbs/prototype/runtime.rb +667 -0
  189. data/lib/rbs/repository.rb +127 -0
  190. data/lib/rbs/resolver/constant_resolver.rb +219 -0
  191. data/lib/rbs/resolver/type_name_resolver.rb +91 -0
  192. data/lib/rbs/sorter.rb +198 -0
  193. data/lib/rbs/substitution.rb +83 -0
  194. data/lib/rbs/subtractor.rb +201 -0
  195. data/lib/rbs/test/errors.rb +80 -0
  196. data/lib/rbs/test/guaranteed.rb +30 -0
  197. data/lib/rbs/test/hook.rb +212 -0
  198. data/lib/rbs/test/observer.rb +19 -0
  199. data/lib/rbs/test/setup.rb +84 -0
  200. data/lib/rbs/test/setup_helper.rb +50 -0
  201. data/lib/rbs/test/tester.rb +167 -0
  202. data/lib/rbs/test/type_check.rb +435 -0
  203. data/lib/rbs/test.rb +112 -0
  204. data/lib/rbs/type_alias_dependency.rb +100 -0
  205. data/lib/rbs/type_alias_regularity.rb +126 -0
  206. data/lib/rbs/type_name.rb +109 -0
  207. data/lib/rbs/types.rb +1596 -0
  208. data/lib/rbs/unit_test/convertibles.rb +176 -0
  209. data/lib/rbs/unit_test/spy.rb +138 -0
  210. data/lib/rbs/unit_test/type_assertions.rb +347 -0
  211. data/lib/rbs/unit_test/with_aliases.rb +143 -0
  212. data/lib/rbs/unit_test.rb +6 -0
  213. data/lib/rbs/validator.rb +186 -0
  214. data/lib/rbs/variance_calculator.rb +189 -0
  215. data/lib/rbs/vendorer.rb +71 -0
  216. data/lib/rbs/version.rb +5 -0
  217. data/lib/rbs/writer.rb +424 -0
  218. data/lib/rbs.rb +94 -0
  219. data/lib/rdoc/discover.rb +20 -0
  220. data/lib/rdoc_plugin/parser.rb +163 -0
  221. data/rbs-relaxed.gemspec +48 -0
  222. data/schema/annotation.json +14 -0
  223. data/schema/comment.json +26 -0
  224. data/schema/decls.json +326 -0
  225. data/schema/function.json +87 -0
  226. data/schema/location.json +56 -0
  227. data/schema/members.json +266 -0
  228. data/schema/methodType.json +50 -0
  229. data/schema/typeParam.json +36 -0
  230. data/schema/types.json +317 -0
  231. data/sig/ancestor_builder.rbs +163 -0
  232. data/sig/ancestor_graph.rbs +60 -0
  233. data/sig/annotate/annotations.rbs +102 -0
  234. data/sig/annotate/formatter.rbs +24 -0
  235. data/sig/annotate/rdoc_annotater.rbs +82 -0
  236. data/sig/annotate/rdoc_source.rbs +30 -0
  237. data/sig/annotation.rbs +27 -0
  238. data/sig/buffer.rbs +32 -0
  239. data/sig/builtin_names.rbs +44 -0
  240. data/sig/cli/colored_io.rbs +15 -0
  241. data/sig/cli/diff.rbs +21 -0
  242. data/sig/cli/validate.rbs +43 -0
  243. data/sig/cli.rbs +87 -0
  244. data/sig/collection/cleaner.rbs +13 -0
  245. data/sig/collection/config/lockfile.rbs +74 -0
  246. data/sig/collection/config/lockfile_generator.rbs +66 -0
  247. data/sig/collection/config.rbs +46 -0
  248. data/sig/collection/installer.rbs +17 -0
  249. data/sig/collection/sources.rbs +214 -0
  250. data/sig/collection.rbs +4 -0
  251. data/sig/comment.rbs +26 -0
  252. data/sig/constant.rbs +21 -0
  253. data/sig/declarations.rbs +267 -0
  254. data/sig/definition.rbs +173 -0
  255. data/sig/definition_builder.rbs +165 -0
  256. data/sig/diff.rbs +28 -0
  257. data/sig/directives.rbs +77 -0
  258. data/sig/environment.rbs +279 -0
  259. data/sig/environment_loader.rbs +111 -0
  260. data/sig/environment_walker.rbs +65 -0
  261. data/sig/errors.rbs +405 -0
  262. data/sig/factory.rbs +5 -0
  263. data/sig/file_finder.rbs +28 -0
  264. data/sig/location.rbs +110 -0
  265. data/sig/locator.rbs +58 -0
  266. data/sig/manifest.yaml +7 -0
  267. data/sig/members.rbs +258 -0
  268. data/sig/method_builder.rbs +84 -0
  269. data/sig/method_types.rbs +58 -0
  270. data/sig/namespace.rbs +146 -0
  271. data/sig/parser.rbs +100 -0
  272. data/sig/prototype/helpers.rbs +27 -0
  273. data/sig/prototype/node_usage.rbs +20 -0
  274. data/sig/prototype/rb.rbs +96 -0
  275. data/sig/prototype/rbi.rbs +75 -0
  276. data/sig/prototype/runtime.rbs +182 -0
  277. data/sig/rbs.rbs +21 -0
  278. data/sig/rdoc/rbs.rbs +67 -0
  279. data/sig/repository.rbs +85 -0
  280. data/sig/resolver/constant_resolver.rbs +92 -0
  281. data/sig/resolver/context.rbs +34 -0
  282. data/sig/resolver/type_name_resolver.rbs +35 -0
  283. data/sig/shims/bundler.rbs +38 -0
  284. data/sig/shims/enumerable.rbs +5 -0
  285. data/sig/shims/rubygems.rbs +19 -0
  286. data/sig/sorter.rbs +41 -0
  287. data/sig/substitution.rbs +48 -0
  288. data/sig/subtractor.rbs +37 -0
  289. data/sig/test/errors.rbs +52 -0
  290. data/sig/test/guranteed.rbs +9 -0
  291. data/sig/test/type_check.rbs +19 -0
  292. data/sig/test.rbs +82 -0
  293. data/sig/type_alias_dependency.rbs +53 -0
  294. data/sig/type_alias_regularity.rbs +98 -0
  295. data/sig/type_param.rbs +110 -0
  296. data/sig/typename.rbs +79 -0
  297. data/sig/types.rbs +579 -0
  298. data/sig/unit_test/convertibles.rbs +154 -0
  299. data/sig/unit_test/spy.rbs +30 -0
  300. data/sig/unit_test/type_assertions.rbs +196 -0
  301. data/sig/unit_test/with_aliases.rbs +136 -0
  302. data/sig/use_map.rbs +35 -0
  303. data/sig/util.rbs +9 -0
  304. data/sig/validator.rbs +63 -0
  305. data/sig/variance_calculator.rbs +87 -0
  306. data/sig/vendorer.rbs +51 -0
  307. data/sig/version.rbs +3 -0
  308. data/sig/visitor.rbs +47 -0
  309. data/sig/writer.rbs +127 -0
  310. data/src/constants.c +153 -0
  311. data/src/ruby_objs.c +795 -0
  312. data/src/util/rbs_constant_pool.c +342 -0
  313. data/stdlib/abbrev/0/abbrev.rbs +66 -0
  314. data/stdlib/abbrev/0/array.rbs +26 -0
  315. data/stdlib/base64/0/base64.rbs +355 -0
  316. data/stdlib/benchmark/0/benchmark.rbs +452 -0
  317. data/stdlib/bigdecimal/0/big_decimal.rbs +1629 -0
  318. data/stdlib/bigdecimal-math/0/big_math.rbs +119 -0
  319. data/stdlib/bigdecimal-math/0/manifest.yaml +2 -0
  320. data/stdlib/cgi/0/core.rbs +1285 -0
  321. data/stdlib/cgi/0/manifest.yaml +3 -0
  322. data/stdlib/coverage/0/coverage.rbs +263 -0
  323. data/stdlib/csv/0/csv.rbs +3776 -0
  324. data/stdlib/csv/0/manifest.yaml +3 -0
  325. data/stdlib/date/0/date.rbs +1585 -0
  326. data/stdlib/date/0/date_time.rbs +616 -0
  327. data/stdlib/date/0/time.rbs +26 -0
  328. data/stdlib/dbm/0/dbm.rbs +421 -0
  329. data/stdlib/delegate/0/delegator.rbs +184 -0
  330. data/stdlib/delegate/0/kernel.rbs +47 -0
  331. data/stdlib/delegate/0/simple_delegator.rbs +96 -0
  332. data/stdlib/did_you_mean/0/did_you_mean.rbs +343 -0
  333. data/stdlib/digest/0/digest.rbs +577 -0
  334. data/stdlib/erb/0/erb.rbs +532 -0
  335. data/stdlib/etc/0/etc.rbs +865 -0
  336. data/stdlib/fileutils/0/fileutils.rbs +1734 -0
  337. data/stdlib/find/0/find.rbs +49 -0
  338. data/stdlib/forwardable/0/forwardable.rbs +268 -0
  339. data/stdlib/io-console/0/io-console.rbs +414 -0
  340. data/stdlib/ipaddr/0/ipaddr.rbs +428 -0
  341. data/stdlib/json/0/json.rbs +1916 -0
  342. data/stdlib/kconv/0/kconv.rbs +166 -0
  343. data/stdlib/logger/0/formatter.rbs +45 -0
  344. data/stdlib/logger/0/log_device.rbs +100 -0
  345. data/stdlib/logger/0/logger.rbs +796 -0
  346. data/stdlib/logger/0/manifest.yaml +2 -0
  347. data/stdlib/logger/0/period.rbs +17 -0
  348. data/stdlib/logger/0/severity.rbs +34 -0
  349. data/stdlib/minitest/0/kernel.rbs +42 -0
  350. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +52 -0
  351. data/stdlib/minitest/0/minitest/assertion.rbs +17 -0
  352. data/stdlib/minitest/0/minitest/assertions.rbs +590 -0
  353. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +23 -0
  354. data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
  355. data/stdlib/minitest/0/minitest/benchmark.rbs +259 -0
  356. data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
  357. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  358. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  359. data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
  360. data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
  361. data/stdlib/minitest/0/minitest/guard.rbs +64 -0
  362. data/stdlib/minitest/0/minitest/mock.rbs +64 -0
  363. data/stdlib/minitest/0/minitest/parallel/executor.rbs +46 -0
  364. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +5 -0
  365. data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
  366. data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
  367. data/stdlib/minitest/0/minitest/pride_io.rbs +62 -0
  368. data/stdlib/minitest/0/minitest/pride_lol.rbs +19 -0
  369. data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
  370. data/stdlib/minitest/0/minitest/reportable.rbs +53 -0
  371. data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
  372. data/stdlib/minitest/0/minitest/result.rbs +28 -0
  373. data/stdlib/minitest/0/minitest/runnable.rbs +163 -0
  374. data/stdlib/minitest/0/minitest/skip.rbs +6 -0
  375. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
  376. data/stdlib/minitest/0/minitest/spec/dsl.rbs +129 -0
  377. data/stdlib/minitest/0/minitest/spec.rbs +11 -0
  378. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +81 -0
  379. data/stdlib/minitest/0/minitest/summary_reporter.rbs +18 -0
  380. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
  381. data/stdlib/minitest/0/minitest/test.rbs +69 -0
  382. data/stdlib/minitest/0/minitest/unexpected_error.rbs +12 -0
  383. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  384. data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
  385. data/stdlib/minitest/0/minitest/unit.rbs +4 -0
  386. data/stdlib/minitest/0/minitest.rbs +115 -0
  387. data/stdlib/monitor/0/monitor.rbs +363 -0
  388. data/stdlib/mutex_m/0/mutex_m.rbs +104 -0
  389. data/stdlib/net-http/0/manifest.yaml +3 -0
  390. data/stdlib/net-http/0/net-http.rbs +5552 -0
  391. data/stdlib/net-protocol/0/manifest.yaml +2 -0
  392. data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
  393. data/stdlib/net-smtp/0/manifest.yaml +2 -0
  394. data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
  395. data/stdlib/nkf/0/nkf.rbs +402 -0
  396. data/stdlib/objspace/0/objspace.rbs +487 -0
  397. data/stdlib/observable/0/observable.rbs +217 -0
  398. data/stdlib/open-uri/0/manifest.yaml +4 -0
  399. data/stdlib/open-uri/0/open-uri.rbs +393 -0
  400. data/stdlib/open3/0/open3.rbs +147 -0
  401. data/stdlib/openssl/0/manifest.yaml +3 -0
  402. data/stdlib/openssl/0/openssl.rbs +12113 -0
  403. data/stdlib/optparse/0/optparse.rbs +1725 -0
  404. data/stdlib/pathname/0/pathname.rbs +1406 -0
  405. data/stdlib/pp/0/manifest.yaml +2 -0
  406. data/stdlib/pp/0/pp.rbs +300 -0
  407. data/stdlib/prettyprint/0/prettyprint.rbs +383 -0
  408. data/stdlib/pstore/0/pstore.rbs +603 -0
  409. data/stdlib/psych/0/core_ext.rbs +12 -0
  410. data/stdlib/psych/0/dbm.rbs +237 -0
  411. data/stdlib/psych/0/manifest.yaml +3 -0
  412. data/stdlib/psych/0/psych.rbs +402 -0
  413. data/stdlib/psych/0/store.rbs +59 -0
  414. data/stdlib/pty/0/pty.rbs +237 -0
  415. data/stdlib/rdoc/0/code_object.rbs +51 -0
  416. data/stdlib/rdoc/0/comment.rbs +59 -0
  417. data/stdlib/rdoc/0/context.rbs +153 -0
  418. data/stdlib/rdoc/0/markup.rbs +117 -0
  419. data/stdlib/rdoc/0/parser.rbs +56 -0
  420. data/stdlib/rdoc/0/rdoc.rbs +391 -0
  421. data/stdlib/rdoc/0/ri.rbs +17 -0
  422. data/stdlib/rdoc/0/store.rbs +48 -0
  423. data/stdlib/rdoc/0/top_level.rbs +97 -0
  424. data/stdlib/resolv/0/manifest.yaml +3 -0
  425. data/stdlib/resolv/0/resolv.rbs +1830 -0
  426. data/stdlib/ripper/0/ripper.rbs +1648 -0
  427. data/stdlib/securerandom/0/securerandom.rbs +62 -0
  428. data/stdlib/shellwords/0/shellwords.rbs +229 -0
  429. data/stdlib/singleton/0/singleton.rbs +131 -0
  430. data/stdlib/socket/0/addrinfo.rbs +666 -0
  431. data/stdlib/socket/0/basic_socket.rbs +590 -0
  432. data/stdlib/socket/0/constants.rbs +2295 -0
  433. data/stdlib/socket/0/ip_socket.rbs +92 -0
  434. data/stdlib/socket/0/socket.rbs +4157 -0
  435. data/stdlib/socket/0/socket_error.rbs +5 -0
  436. data/stdlib/socket/0/tcp_server.rbs +192 -0
  437. data/stdlib/socket/0/tcp_socket.rbs +79 -0
  438. data/stdlib/socket/0/udp_socket.rbs +133 -0
  439. data/stdlib/socket/0/unix_server.rbs +169 -0
  440. data/stdlib/socket/0/unix_socket.rbs +172 -0
  441. data/stdlib/stringio/0/stringio.rbs +567 -0
  442. data/stdlib/strscan/0/string_scanner.rbs +1627 -0
  443. data/stdlib/tempfile/0/tempfile.rbs +479 -0
  444. data/stdlib/time/0/time.rbs +432 -0
  445. data/stdlib/timeout/0/timeout.rbs +81 -0
  446. data/stdlib/tmpdir/0/tmpdir.rbs +69 -0
  447. data/stdlib/tsort/0/cyclic.rbs +5 -0
  448. data/stdlib/tsort/0/interfaces.rbs +20 -0
  449. data/stdlib/tsort/0/tsort.rbs +409 -0
  450. data/stdlib/uri/0/common.rbs +582 -0
  451. data/stdlib/uri/0/file.rbs +118 -0
  452. data/stdlib/uri/0/ftp.rbs +13 -0
  453. data/stdlib/uri/0/generic.rbs +1108 -0
  454. data/stdlib/uri/0/http.rbs +104 -0
  455. data/stdlib/uri/0/https.rbs +14 -0
  456. data/stdlib/uri/0/ldap.rbs +230 -0
  457. data/stdlib/uri/0/ldaps.rbs +14 -0
  458. data/stdlib/uri/0/mailto.rbs +92 -0
  459. data/stdlib/uri/0/rfc2396_parser.rbs +189 -0
  460. data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
  461. data/stdlib/uri/0/ws.rbs +13 -0
  462. data/stdlib/uri/0/wss.rbs +9 -0
  463. data/stdlib/yaml/0/manifest.yaml +2 -0
  464. data/stdlib/yaml/0/yaml.rbs +1 -0
  465. data/stdlib/zlib/0/buf_error.rbs +10 -0
  466. data/stdlib/zlib/0/data_error.rbs +10 -0
  467. data/stdlib/zlib/0/deflate.rbs +210 -0
  468. data/stdlib/zlib/0/error.rbs +20 -0
  469. data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
  470. data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
  471. data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
  472. data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
  473. data/stdlib/zlib/0/gzip_file.rbs +156 -0
  474. data/stdlib/zlib/0/gzip_reader.rbs +293 -0
  475. data/stdlib/zlib/0/gzip_writer.rbs +166 -0
  476. data/stdlib/zlib/0/inflate.rbs +180 -0
  477. data/stdlib/zlib/0/mem_error.rbs +10 -0
  478. data/stdlib/zlib/0/need_dict.rbs +13 -0
  479. data/stdlib/zlib/0/stream_end.rbs +11 -0
  480. data/stdlib/zlib/0/stream_error.rbs +11 -0
  481. data/stdlib/zlib/0/version_error.rbs +11 -0
  482. data/stdlib/zlib/0/zlib.rbs +449 -0
  483. data/stdlib/zlib/0/zstream.rbs +200 -0
  484. metadata +532 -0
data/core/thread.rbs ADDED
@@ -0,0 +1,1765 @@
1
+ # <!-- rdoc-file=vm.c -->
2
+ # Threads are the Ruby implementation for a concurrent programming model.
3
+ #
4
+ # Programs that require multiple threads of execution are a perfect candidate
5
+ # for Ruby's Thread class.
6
+ #
7
+ # For example, we can create a new thread separate from the main thread's
8
+ # execution using ::new.
9
+ #
10
+ # thr = Thread.new { puts "What's the big deal" }
11
+ #
12
+ # Then we are able to pause the execution of the main thread and allow our new
13
+ # thread to finish, using #join:
14
+ #
15
+ # thr.join #=> "What's the big deal"
16
+ #
17
+ # If we don't call `thr.join` before the main thread terminates, then all other
18
+ # threads including `thr` will be killed.
19
+ #
20
+ # Alternatively, you can use an array for handling multiple threads at once,
21
+ # like in the following example:
22
+ #
23
+ # threads = []
24
+ # threads << Thread.new { puts "What's the big deal" }
25
+ # threads << Thread.new { 3.times { puts "Threads are fun!" } }
26
+ #
27
+ # After creating a few threads we wait for them all to finish consecutively.
28
+ #
29
+ # threads.each { |thr| thr.join }
30
+ #
31
+ # To retrieve the last value of a thread, use #value
32
+ #
33
+ # thr = Thread.new { sleep 1; "Useful value" }
34
+ # thr.value #=> "Useful value"
35
+ #
36
+ # ### Thread initialization
37
+ #
38
+ # In order to create new threads, Ruby provides ::new, ::start, and ::fork. A
39
+ # block must be provided with each of these methods, otherwise a ThreadError
40
+ # will be raised.
41
+ #
42
+ # When subclassing the Thread class, the `initialize` method of your subclass
43
+ # will be ignored by ::start and ::fork. Otherwise, be sure to call super in
44
+ # your `initialize` method.
45
+ #
46
+ # ### Thread termination
47
+ #
48
+ # For terminating threads, Ruby provides a variety of ways to do this.
49
+ #
50
+ # The class method ::kill, is meant to exit a given thread:
51
+ #
52
+ # thr = Thread.new { sleep }
53
+ # Thread.kill(thr) # sends exit() to thr
54
+ #
55
+ # Alternatively, you can use the instance method #exit, or any of its aliases
56
+ # #kill or #terminate.
57
+ #
58
+ # thr.exit
59
+ #
60
+ # ### Thread status
61
+ #
62
+ # Ruby provides a few instance methods for querying the state of a given thread.
63
+ # To get a string with the current thread's state use #status
64
+ #
65
+ # thr = Thread.new { sleep }
66
+ # thr.status # => "sleep"
67
+ # thr.exit
68
+ # thr.status # => false
69
+ #
70
+ # You can also use #alive? to tell if the thread is running or sleeping, and
71
+ # #stop? if the thread is dead or sleeping.
72
+ #
73
+ # ### Thread variables and scope
74
+ #
75
+ # Since threads are created with blocks, the same rules apply to other Ruby
76
+ # blocks for variable scope. Any local variables created within this block are
77
+ # accessible to only this thread.
78
+ #
79
+ # #### Fiber-local vs. Thread-local
80
+ #
81
+ # Each fiber has its own bucket for Thread#[] storage. When you set a new
82
+ # fiber-local it is only accessible within this Fiber. To illustrate:
83
+ #
84
+ # Thread.new {
85
+ # Thread.current[:foo] = "bar"
86
+ # Fiber.new {
87
+ # p Thread.current[:foo] # => nil
88
+ # }.resume
89
+ # }.join
90
+ #
91
+ # This example uses #[] for getting and #[]= for setting fiber-locals, you can
92
+ # also use #keys to list the fiber-locals for a given thread and #key? to check
93
+ # if a fiber-local exists.
94
+ #
95
+ # When it comes to thread-locals, they are accessible within the entire scope of
96
+ # the thread. Given the following example:
97
+ #
98
+ # Thread.new{
99
+ # Thread.current.thread_variable_set(:foo, 1)
100
+ # p Thread.current.thread_variable_get(:foo) # => 1
101
+ # Fiber.new{
102
+ # Thread.current.thread_variable_set(:foo, 2)
103
+ # p Thread.current.thread_variable_get(:foo) # => 2
104
+ # }.resume
105
+ # p Thread.current.thread_variable_get(:foo) # => 2
106
+ # }.join
107
+ #
108
+ # You can see that the thread-local `:foo` carried over into the fiber and was
109
+ # changed to `2` by the end of the thread.
110
+ #
111
+ # This example makes use of #thread_variable_set to create new thread-locals,
112
+ # and #thread_variable_get to reference them.
113
+ #
114
+ # There is also #thread_variables to list all thread-locals, and
115
+ # #thread_variable? to check if a given thread-local exists.
116
+ #
117
+ # ### Exception handling
118
+ #
119
+ # When an unhandled exception is raised inside a thread, it will terminate. By
120
+ # default, this exception will not propagate to other threads. The exception is
121
+ # stored and when another thread calls #value or #join, the exception will be
122
+ # re-raised in that thread.
123
+ #
124
+ # t = Thread.new{ raise 'something went wrong' }
125
+ # t.value #=> RuntimeError: something went wrong
126
+ #
127
+ # An exception can be raised from outside the thread using the Thread#raise
128
+ # instance method, which takes the same parameters as Kernel#raise.
129
+ #
130
+ # Setting Thread.abort_on_exception = true, Thread#abort_on_exception = true, or
131
+ # $DEBUG = true will cause a subsequent unhandled exception raised in a thread
132
+ # to be automatically re-raised in the main thread.
133
+ #
134
+ # With the addition of the class method ::handle_interrupt, you can now handle
135
+ # exceptions asynchronously with threads.
136
+ #
137
+ # ### Scheduling
138
+ #
139
+ # Ruby provides a few ways to support scheduling threads in your program.
140
+ #
141
+ # The first way is by using the class method ::stop, to put the current running
142
+ # thread to sleep and schedule the execution of another thread.
143
+ #
144
+ # Once a thread is asleep, you can use the instance method #wakeup to mark your
145
+ # thread as eligible for scheduling.
146
+ #
147
+ # You can also try ::pass, which attempts to pass execution to another thread
148
+ # but is dependent on the OS whether a running thread will switch or not. The
149
+ # same goes for #priority, which lets you hint to the thread scheduler which
150
+ # threads you want to take precedence when passing execution. This method is
151
+ # also dependent on the OS and may be ignored on some platforms.
152
+ #
153
+ class Thread < Object
154
+ # <!--
155
+ # rdoc-file=thread.c
156
+ # - Thread.current -> thread
157
+ # -->
158
+ # Returns the currently executing thread.
159
+ #
160
+ # Thread.current #=> #<Thread:0x401bdf4c run>
161
+ #
162
+ def self.current: () -> Thread
163
+
164
+ # <!--
165
+ # rdoc-file=thread.c
166
+ # - Thread.main -> thread
167
+ # -->
168
+ # Returns the main thread.
169
+ #
170
+ def self.main: () -> Thread
171
+
172
+ # <!--
173
+ # rdoc-file=thread.c
174
+ # - thr[sym] -> obj or nil
175
+ # -->
176
+ # Attribute Reference---Returns the value of a fiber-local variable (current
177
+ # thread's root fiber if not explicitly inside a Fiber), using either a symbol
178
+ # or a string name. If the specified variable does not exist, returns `nil`.
179
+ #
180
+ # [
181
+ # Thread.new { Thread.current["name"] = "A" },
182
+ # Thread.new { Thread.current[:name] = "B" },
183
+ # Thread.new { Thread.current["name"] = "C" }
184
+ # ].each do |th|
185
+ # th.join
186
+ # puts "#{th.inspect}: #{th[:name]}"
187
+ # end
188
+ #
189
+ # This will produce:
190
+ #
191
+ # #<Thread:0x00000002a54220 dead>: A
192
+ # #<Thread:0x00000002a541a8 dead>: B
193
+ # #<Thread:0x00000002a54130 dead>: C
194
+ #
195
+ # Thread#[] and Thread#[]= are not thread-local but fiber-local. This confusion
196
+ # did not exist in Ruby 1.8 because fibers are only available since Ruby 1.9.
197
+ # Ruby 1.9 chooses that the methods behaves fiber-local to save following idiom
198
+ # for dynamic scope.
199
+ #
200
+ # def meth(newvalue)
201
+ # begin
202
+ # oldvalue = Thread.current[:name]
203
+ # Thread.current[:name] = newvalue
204
+ # yield
205
+ # ensure
206
+ # Thread.current[:name] = oldvalue
207
+ # end
208
+ # end
209
+ #
210
+ # The idiom may not work as dynamic scope if the methods are thread-local and a
211
+ # given block switches fiber.
212
+ #
213
+ # f = Fiber.new {
214
+ # meth(1) {
215
+ # Fiber.yield
216
+ # }
217
+ # }
218
+ # meth(2) {
219
+ # f.resume
220
+ # }
221
+ # f.resume
222
+ # p Thread.current[:name]
223
+ # #=> nil if fiber-local
224
+ # #=> 2 if thread-local (The value 2 is leaked to outside of meth method.)
225
+ #
226
+ # For thread-local variables, please see #thread_variable_get and
227
+ # #thread_variable_set.
228
+ #
229
+ def []: (interned key) -> untyped
230
+
231
+ # <!--
232
+ # rdoc-file=thread.c
233
+ # - thr[sym] = obj -> obj
234
+ # -->
235
+ # Attribute Assignment---Sets or creates the value of a fiber-local variable,
236
+ # using either a symbol or a string.
237
+ #
238
+ # See also Thread#[].
239
+ #
240
+ # For thread-local variables, please see #thread_variable_set and
241
+ # #thread_variable_get.
242
+ #
243
+ def []=: (interned key, untyped value) -> untyped
244
+
245
+ # <!--
246
+ # rdoc-file=thread.c
247
+ # - thr.alive? -> true or false
248
+ # -->
249
+ # Returns `true` if `thr` is running or sleeping.
250
+ #
251
+ # thr = Thread.new { }
252
+ # thr.join #=> #<Thread:0x401b3fb0 dead>
253
+ # Thread.current.alive? #=> true
254
+ # thr.alive? #=> false
255
+ #
256
+ # See also #stop? and #status.
257
+ #
258
+ def alive?: () -> bool
259
+
260
+ # <!--
261
+ # rdoc-file=thread.c
262
+ # - thr.exit -> thr
263
+ # - thr.kill -> thr
264
+ # - thr.terminate -> thr
265
+ # -->
266
+ # Terminates `thr` and schedules another thread to be run, returning the
267
+ # terminated Thread. If this is the main thread, or the last thread, exits the
268
+ # process.
269
+ #
270
+ def kill: () -> Thread?
271
+
272
+ # <!--
273
+ # rdoc-file=thread.c
274
+ # - thr.abort_on_exception -> true or false
275
+ # -->
276
+ # Returns the status of the thread-local ``abort on exception'' condition for
277
+ # this `thr`.
278
+ #
279
+ # The default is `false`.
280
+ #
281
+ # See also #abort_on_exception=.
282
+ #
283
+ # There is also a class level method to set this for all threads, see
284
+ # ::abort_on_exception.
285
+ #
286
+ def abort_on_exception: () -> bool
287
+
288
+ # <!--
289
+ # rdoc-file=thread.c
290
+ # - thr.abort_on_exception= boolean -> true or false
291
+ # -->
292
+ # When set to `true`, if this `thr` is aborted by an exception, the raised
293
+ # exception will be re-raised in the main thread.
294
+ #
295
+ # See also #abort_on_exception.
296
+ #
297
+ # There is also a class level method to set this for all threads, see
298
+ # ::abort_on_exception=.
299
+ #
300
+ def abort_on_exception=: (boolish abort_on_exception) -> untyped
301
+
302
+ # <!--
303
+ # rdoc-file=vm_trace.c
304
+ # - thr.add_trace_func(proc) -> proc
305
+ # -->
306
+ # Adds *proc* as a handler for tracing.
307
+ #
308
+ # See Thread#set_trace_func and Kernel#set_trace_func.
309
+ #
310
+ def add_trace_func: (untyped proc) -> untyped
311
+
312
+ # <!--
313
+ # rdoc-file=thread.c
314
+ # - thread.backtrace -> array or nil
315
+ # -->
316
+ # Returns the current backtrace of the target thread.
317
+ #
318
+ def backtrace: (*untyped args) -> ::Array[untyped]
319
+
320
+ # <!--
321
+ # rdoc-file=thread.c
322
+ # - thread.backtrace_locations(*args) -> array or nil
323
+ # -->
324
+ # Returns the execution stack for the target thread---an array containing
325
+ # backtrace location objects.
326
+ #
327
+ # See Thread::Backtrace::Location for more information.
328
+ #
329
+ # This method behaves similarly to Kernel#caller_locations except it applies to
330
+ # a specific thread.
331
+ #
332
+ def backtrace_locations: (*untyped args) -> ::Array[untyped]?
333
+
334
+ # <!-- rdoc-file=thread.c -->
335
+ # Terminates `thr` and schedules another thread to be run, returning the
336
+ # terminated Thread. If this is the main thread, or the last thread, exits the
337
+ # process.
338
+ #
339
+ def exit: () -> Thread?
340
+
341
+ # <!--
342
+ # rdoc-file=thread.c
343
+ # - thr.fetch(sym) -> obj
344
+ # - thr.fetch(sym) { } -> obj
345
+ # - thr.fetch(sym, default) -> obj
346
+ # -->
347
+ # Returns a fiber-local for the given key. If the key can't be found, there are
348
+ # several options: With no other arguments, it will raise a KeyError exception;
349
+ # if *default* is given, then that will be returned; if the optional code block
350
+ # is specified, then that will be run and its result returned. See Thread#[]
351
+ # and Hash#fetch.
352
+ #
353
+ def fetch: (*untyped sym) -> untyped
354
+
355
+ # <!--
356
+ # rdoc-file=thread.c
357
+ # - thr.group -> thgrp or nil
358
+ # -->
359
+ # Returns the ThreadGroup which contains the given thread.
360
+ #
361
+ # Thread.main.group #=> #<ThreadGroup:0x4029d914>
362
+ #
363
+ def group: () -> ThreadGroup?
364
+
365
+ # <!--
366
+ # rdoc-file=thread.c
367
+ # - Thread.new { ... } -> thread
368
+ # - Thread.new(*args, &proc) -> thread
369
+ # - Thread.new(*args) { |args| ... } -> thread
370
+ # -->
371
+ # Creates a new thread executing the given block.
372
+ #
373
+ # Any `args` given to ::new will be passed to the block:
374
+ #
375
+ # arr = []
376
+ # a, b, c = 1, 2, 3
377
+ # Thread.new(a,b,c) { |d,e,f| arr << d << e << f }.join
378
+ # arr #=> [1, 2, 3]
379
+ #
380
+ # A ThreadError exception is raised if ::new is called without a block.
381
+ #
382
+ # If you're going to subclass Thread, be sure to call super in your `initialize`
383
+ # method, otherwise a ThreadError will be raised.
384
+ #
385
+ def initialize: (*untyped) { (?) -> void } -> void
386
+
387
+ # <!--
388
+ # rdoc-file=thread.c
389
+ # - thr.join -> thr
390
+ # - thr.join(limit) -> thr
391
+ # -->
392
+ # The calling thread will suspend execution and run this `thr`.
393
+ #
394
+ # Does not return until `thr` exits or until the given `limit` seconds have
395
+ # passed.
396
+ #
397
+ # If the time limit expires, `nil` will be returned, otherwise `thr` is
398
+ # returned.
399
+ #
400
+ # Any threads not joined will be killed when the main program exits.
401
+ #
402
+ # If `thr` had previously raised an exception and the ::abort_on_exception or
403
+ # $DEBUG flags are not set, (so the exception has not yet been processed), it
404
+ # will be processed at this time.
405
+ #
406
+ # a = Thread.new { print "a"; sleep(10); print "b"; print "c" }
407
+ # x = Thread.new { print "x"; Thread.pass; print "y"; print "z" }
408
+ # x.join # Let thread x finish, thread a will be killed on exit.
409
+ # #=> "axyz"
410
+ #
411
+ # The following example illustrates the `limit` parameter.
412
+ #
413
+ # y = Thread.new { 4.times { sleep 0.1; puts 'tick... ' }}
414
+ # puts "Waiting" until y.join(0.15)
415
+ #
416
+ # This will produce:
417
+ #
418
+ # tick...
419
+ # Waiting
420
+ # tick...
421
+ # Waiting
422
+ # tick...
423
+ # tick...
424
+ #
425
+ def join: (*untyped limit) -> Thread
426
+
427
+ # <!--
428
+ # rdoc-file=thread.c
429
+ # - thr.key?(sym) -> true or false
430
+ # -->
431
+ # Returns `true` if the given string (or symbol) exists as a fiber-local
432
+ # variable.
433
+ #
434
+ # me = Thread.current
435
+ # me[:oliver] = "a"
436
+ # me.key?(:oliver) #=> true
437
+ # me.key?(:stanley) #=> false
438
+ #
439
+ def key?: (Symbol sym) -> bool
440
+
441
+ # <!--
442
+ # rdoc-file=thread.c
443
+ # - thr.keys -> array
444
+ # -->
445
+ # Returns an array of the names of the fiber-local variables (as Symbols).
446
+ #
447
+ # thr = Thread.new do
448
+ # Thread.current[:cat] = 'meow'
449
+ # Thread.current["dog"] = 'woof'
450
+ # end
451
+ # thr.join #=> #<Thread:0x401b3f10 dead>
452
+ # thr.keys #=> [:dog, :cat]
453
+ #
454
+ def keys: () -> ::Array[Symbol]
455
+
456
+ # <!--
457
+ # rdoc-file=thread.c
458
+ # - thr.name -> string
459
+ # -->
460
+ # show the name of the thread.
461
+ #
462
+ def name: () -> String
463
+
464
+ # <!--
465
+ # rdoc-file=thread.c
466
+ # - thr.name=(name) -> string
467
+ # -->
468
+ # set given name to the ruby thread. On some platform, it may set the name to
469
+ # pthread and/or kernel.
470
+ #
471
+ def name=: (untyped name) -> untyped
472
+
473
+ # <!--
474
+ # rdoc-file=thread.c
475
+ # - thr.native_thread_id -> integer
476
+ # -->
477
+ # Return the native thread ID which is used by the Ruby thread.
478
+ #
479
+ # The ID depends on the OS. (not POSIX thread ID returned by pthread_self(3))
480
+ # * On Linux it is TID returned by gettid(2).
481
+ # * On macOS it is the system-wide unique integral ID of thread returned by
482
+ # pthread_threadid_np(3).
483
+ # * On FreeBSD it is the unique integral ID of the thread returned by
484
+ # pthread_getthreadid_np(3).
485
+ # * On Windows it is the thread identifier returned by GetThreadId().
486
+ # * On other platforms, it raises NotImplementedError.
487
+ #
488
+ # NOTE: If the thread is not associated yet or already deassociated with a
489
+ # native thread, it returns *nil*. If the Ruby implementation uses M:N thread
490
+ # model, the ID may change depending on the timing.
491
+ #
492
+ def native_thread_id: () -> Integer
493
+
494
+ # <!--
495
+ # rdoc-file=thread.c
496
+ # - target_thread.pending_interrupt?(error = nil) -> true/false
497
+ # -->
498
+ # Returns whether or not the asynchronous queue is empty for the target thread.
499
+ #
500
+ # If `error` is given, then check only for `error` type deferred events.
501
+ #
502
+ # See ::pending_interrupt? for more information.
503
+ #
504
+ def pending_interrupt?: (*untyped args) -> bool
505
+
506
+ # <!--
507
+ # rdoc-file=thread.c
508
+ # - thr.priority -> integer
509
+ # -->
510
+ # Returns the priority of *thr*. Default is inherited from the current thread
511
+ # which creating the new thread, or zero for the initial main thread;
512
+ # higher-priority thread will run more frequently than lower-priority threads
513
+ # (but lower-priority threads can also run).
514
+ #
515
+ # This is just hint for Ruby thread scheduler. It may be ignored on some
516
+ # platform.
517
+ #
518
+ # Thread.current.priority #=> 0
519
+ #
520
+ def priority: () -> Integer
521
+
522
+ # <!--
523
+ # rdoc-file=thread.c
524
+ # - thr.priority= integer -> thr
525
+ # -->
526
+ # Sets the priority of *thr* to *integer*. Higher-priority threads will run more
527
+ # frequently than lower-priority threads (but lower-priority threads can also
528
+ # run).
529
+ #
530
+ # This is just hint for Ruby thread scheduler. It may be ignored on some
531
+ # platform.
532
+ #
533
+ # count1 = count2 = 0
534
+ # a = Thread.new do
535
+ # loop { count1 += 1 }
536
+ # end
537
+ # a.priority = -1
538
+ #
539
+ # b = Thread.new do
540
+ # loop { count2 += 1 }
541
+ # end
542
+ # b.priority = -2
543
+ # sleep 1 #=> 1
544
+ # count1 #=> 622504
545
+ # count2 #=> 5832
546
+ #
547
+ def priority=: (Integer priority) -> untyped
548
+
549
+ # <!--
550
+ # rdoc-file=thread.c
551
+ # - thr.report_on_exception -> true or false
552
+ # -->
553
+ # Returns the status of the thread-local ``report on exception'' condition for
554
+ # this `thr`.
555
+ #
556
+ # The default value when creating a Thread is the value of the global flag
557
+ # Thread.report_on_exception.
558
+ #
559
+ # See also #report_on_exception=.
560
+ #
561
+ # There is also a class level method to set this for all new threads, see
562
+ # ::report_on_exception=.
563
+ #
564
+ def report_on_exception: () -> bool
565
+
566
+ # <!--
567
+ # rdoc-file=thread.c
568
+ # - thr.report_on_exception= boolean -> true or false
569
+ # -->
570
+ # When set to `true`, a message is printed on $stderr if an exception kills this
571
+ # `thr`. See ::report_on_exception for details.
572
+ #
573
+ # See also #report_on_exception.
574
+ #
575
+ # There is also a class level method to set this for all new threads, see
576
+ # ::report_on_exception=.
577
+ #
578
+ def report_on_exception=: (boolish report_on_exception) -> untyped
579
+
580
+ # <!--
581
+ # rdoc-file=thread.c
582
+ # - thr.run -> thr
583
+ # -->
584
+ # Wakes up `thr`, making it eligible for scheduling.
585
+ #
586
+ # a = Thread.new { puts "a"; Thread.stop; puts "c" }
587
+ # sleep 0.1 while a.status!='sleep'
588
+ # puts "Got here"
589
+ # a.run
590
+ # a.join
591
+ #
592
+ # This will produce:
593
+ #
594
+ # a
595
+ # Got here
596
+ # c
597
+ #
598
+ # See also the instance method #wakeup.
599
+ #
600
+ def run: () -> Thread
601
+
602
+ # Returns the safe level.
603
+ #
604
+ # This method is obsolete because $SAFE is a process global state. Simply
605
+ # check $SAFE.
606
+ def safe_level: () -> Integer
607
+
608
+ # <!--
609
+ # rdoc-file=thread.c
610
+ # - thr.status -> string, false or nil
611
+ # -->
612
+ # Returns the status of `thr`.
613
+ #
614
+ # `"sleep"`
615
+ # : Returned if this thread is sleeping or waiting on I/O
616
+ #
617
+ # `"run"`
618
+ # : When this thread is executing
619
+ #
620
+ # `"aborting"`
621
+ # : If this thread is aborting
622
+ #
623
+ # `false`
624
+ # : When this thread is terminated normally
625
+ #
626
+ # `nil`
627
+ # : If terminated with an exception.
628
+ #
629
+ #
630
+ # a = Thread.new { raise("die now") }
631
+ # b = Thread.new { Thread.stop }
632
+ # c = Thread.new { Thread.exit }
633
+ # d = Thread.new { sleep }
634
+ # d.kill #=> #<Thread:0x401b3678 aborting>
635
+ # a.status #=> nil
636
+ # b.status #=> "sleep"
637
+ # c.status #=> false
638
+ # d.status #=> "aborting"
639
+ # Thread.current.status #=> "run"
640
+ #
641
+ # See also the instance methods #alive? and #stop?
642
+ #
643
+ def status: () -> (String | bool)?
644
+
645
+ # <!--
646
+ # rdoc-file=thread.c
647
+ # - thr.stop? -> true or false
648
+ # -->
649
+ # Returns `true` if `thr` is dead or sleeping.
650
+ #
651
+ # a = Thread.new { Thread.stop }
652
+ # b = Thread.current
653
+ # a.stop? #=> true
654
+ # b.stop? #=> false
655
+ #
656
+ # See also #alive? and #status.
657
+ #
658
+ def stop?: () -> bool
659
+
660
+ # <!-- rdoc-file=thread.c -->
661
+ # Terminates `thr` and schedules another thread to be run, returning the
662
+ # terminated Thread. If this is the main thread, or the last thread, exits the
663
+ # process.
664
+ #
665
+ def terminate: () -> Thread?
666
+
667
+ # <!--
668
+ # rdoc-file=thread.c
669
+ # - thr.thread_variable?(key) -> true or false
670
+ # -->
671
+ # Returns `true` if the given string (or symbol) exists as a thread-local
672
+ # variable.
673
+ #
674
+ # me = Thread.current
675
+ # me.thread_variable_set(:oliver, "a")
676
+ # me.thread_variable?(:oliver) #=> true
677
+ # me.thread_variable?(:stanley) #=> false
678
+ #
679
+ # Note that these are not fiber local variables. Please see Thread#[] and
680
+ # Thread#thread_variable_get for more details.
681
+ #
682
+ def thread_variable?: (interned key) -> bool
683
+
684
+ # <!--
685
+ # rdoc-file=thread.c
686
+ # - thr.thread_variable_get(key) -> obj or nil
687
+ # -->
688
+ # Returns the value of a thread local variable that has been set. Note that
689
+ # these are different than fiber local values. For fiber local values, please
690
+ # see Thread#[] and Thread#[]=.
691
+ #
692
+ # Thread local values are carried along with threads, and do not respect fibers.
693
+ # For example:
694
+ #
695
+ # Thread.new {
696
+ # Thread.current.thread_variable_set("foo", "bar") # set a thread local
697
+ # Thread.current["foo"] = "bar" # set a fiber local
698
+ #
699
+ # Fiber.new {
700
+ # Fiber.yield [
701
+ # Thread.current.thread_variable_get("foo"), # get the thread local
702
+ # Thread.current["foo"], # get the fiber local
703
+ # ]
704
+ # }.resume
705
+ # }.join.value # => ['bar', nil]
706
+ #
707
+ # The value "bar" is returned for the thread local, where nil is returned for
708
+ # the fiber local. The fiber is executed in the same thread, so the thread
709
+ # local values are available.
710
+ #
711
+ def thread_variable_get: (untyped key) -> untyped
712
+
713
+ # <!--
714
+ # rdoc-file=thread.c
715
+ # - thr.thread_variable_set(key, value)
716
+ # -->
717
+ # Sets a thread local with `key` to `value`. Note that these are local to
718
+ # threads, and not to fibers. Please see Thread#thread_variable_get and
719
+ # Thread#[] for more information.
720
+ #
721
+ def thread_variable_set: (untyped key, untyped value) -> untyped
722
+
723
+ # <!--
724
+ # rdoc-file=thread.c
725
+ # - thr.thread_variables -> array
726
+ # -->
727
+ # Returns an array of the names of the thread-local variables (as Symbols).
728
+ #
729
+ # thr = Thread.new do
730
+ # Thread.current.thread_variable_set(:cat, 'meow')
731
+ # Thread.current.thread_variable_set("dog", 'woof')
732
+ # end
733
+ # thr.join #=> #<Thread:0x401b3f10 dead>
734
+ # thr.thread_variables #=> [:dog, :cat]
735
+ #
736
+ # Note that these are not fiber local variables. Please see Thread#[] and
737
+ # Thread#thread_variable_get for more details.
738
+ #
739
+ def thread_variables: () -> ::Array[Symbol]
740
+
741
+ # <!--
742
+ # rdoc-file=thread.c
743
+ # - thr.value -> obj
744
+ # -->
745
+ # Waits for `thr` to complete, using #join, and returns its value or raises the
746
+ # exception which terminated the thread.
747
+ #
748
+ # a = Thread.new { 2 + 2 }
749
+ # a.value #=> 4
750
+ #
751
+ # b = Thread.new { raise 'something went wrong' }
752
+ # b.value #=> RuntimeError: something went wrong
753
+ #
754
+ def value: () -> untyped
755
+
756
+ # <!--
757
+ # rdoc-file=thread.c
758
+ # - thr.wakeup -> thr
759
+ # -->
760
+ # Marks a given thread as eligible for scheduling, however it may still remain
761
+ # blocked on I/O.
762
+ #
763
+ # **Note:** This does not invoke the scheduler, see #run for more information.
764
+ #
765
+ # c = Thread.new { Thread.stop; puts "hey!" }
766
+ # sleep 0.1 while c.status!='sleep'
767
+ # c.wakeup
768
+ # c.join
769
+ # #=> "hey!"
770
+ #
771
+ def wakeup: () -> Thread
772
+
773
+ # <!--
774
+ # rdoc-file=thread.c
775
+ # - Thread.abort_on_exception -> true or false
776
+ # -->
777
+ # Returns the status of the global ``abort on exception'' condition.
778
+ #
779
+ # The default is `false`.
780
+ #
781
+ # When set to `true`, if any thread is aborted by an exception, the raised
782
+ # exception will be re-raised in the main thread.
783
+ #
784
+ # Can also be specified by the global $DEBUG flag or command line option `-d`.
785
+ #
786
+ # See also ::abort_on_exception=.
787
+ #
788
+ # There is also an instance level method to set this for a specific thread, see
789
+ # #abort_on_exception.
790
+ #
791
+ def self.abort_on_exception: () -> untyped
792
+
793
+ # <!--
794
+ # rdoc-file=thread.c
795
+ # - Thread.abort_on_exception= boolean -> true or false
796
+ # -->
797
+ # When set to `true`, if any thread is aborted by an exception, the raised
798
+ # exception will be re-raised in the main thread. Returns the new state.
799
+ #
800
+ # Thread.abort_on_exception = true
801
+ # t1 = Thread.new do
802
+ # puts "In new thread"
803
+ # raise "Exception from thread"
804
+ # end
805
+ # sleep(1)
806
+ # puts "not reached"
807
+ #
808
+ # This will produce:
809
+ #
810
+ # In new thread
811
+ # prog.rb:4: Exception from thread (RuntimeError)
812
+ # from prog.rb:2:in `initialize'
813
+ # from prog.rb:2:in `new'
814
+ # from prog.rb:2
815
+ #
816
+ # See also ::abort_on_exception.
817
+ #
818
+ # There is also an instance level method to set this for a specific thread, see
819
+ # #abort_on_exception=.
820
+ #
821
+ def self.abort_on_exception=: (untyped abort_on_exception) -> untyped
822
+
823
+ # <!--
824
+ # rdoc-file=vm_backtrace.c
825
+ # - Thread.each_caller_location(...) { |loc| ... } -> nil
826
+ # -->
827
+ # Yields each frame of the current execution stack as a backtrace location
828
+ # object.
829
+ #
830
+ def self.each_caller_location: () { (Backtrace::Location) -> void } -> nil
831
+
832
+ # Wraps the block in a single, VM-global
833
+ # [Mutex\#synchronize](https://ruby-doc.org/core-2.6.3/Mutex.html#method-i-synchronize)
834
+ # , returning the value of the block. A thread executing inside the
835
+ # exclusive section will only block other threads which also use the
836
+ # [::exclusive](Thread.downloaded.ruby_doc#method-c-exclusive) mechanism.
837
+ def self.exclusive: () { () -> untyped } -> untyped
838
+
839
+ # <!--
840
+ # rdoc-file=thread.c
841
+ # - Thread.exit -> thread
842
+ # -->
843
+ # Terminates the currently running thread and schedules another thread to be
844
+ # run.
845
+ #
846
+ # If this thread is already marked to be killed, ::exit returns the Thread.
847
+ #
848
+ # If this is the main thread, or the last thread, exit the process.
849
+ #
850
+ def self.exit: () -> untyped
851
+
852
+ # <!--
853
+ # rdoc-file=thread.c
854
+ # - Thread.start([args]*) {|args| block } -> thread
855
+ # - Thread.fork([args]*) {|args| block } -> thread
856
+ # -->
857
+ # Basically the same as ::new. However, if class Thread is subclassed, then
858
+ # calling `start` in that subclass will not invoke the subclass's `initialize`
859
+ # method.
860
+ #
861
+ def self.fork: (*untyped args) -> untyped
862
+
863
+ # <!--
864
+ # rdoc-file=thread.c
865
+ # - Thread.handle_interrupt(hash) { ... } -> result of the block
866
+ # -->
867
+ # Changes asynchronous interrupt timing.
868
+ #
869
+ # *interrupt* means asynchronous event and corresponding procedure by
870
+ # Thread#raise, Thread#kill, signal trap (not supported yet) and main thread
871
+ # termination (if main thread terminates, then all other thread will be killed).
872
+ #
873
+ # The given `hash` has pairs like `ExceptionClass => :TimingSymbol`. Where the
874
+ # ExceptionClass is the interrupt handled by the given block. The TimingSymbol
875
+ # can be one of the following symbols:
876
+ #
877
+ # `:immediate`
878
+ # : Invoke interrupts immediately.
879
+ #
880
+ # `:on_blocking`
881
+ # : Invoke interrupts while *BlockingOperation*.
882
+ #
883
+ # `:never`
884
+ # : Never invoke all interrupts.
885
+ #
886
+ #
887
+ # *BlockingOperation* means that the operation will block the calling thread,
888
+ # such as read and write. On CRuby implementation, *BlockingOperation* is any
889
+ # operation executed without GVL.
890
+ #
891
+ # Masked asynchronous interrupts are delayed until they are enabled. This method
892
+ # is similar to sigprocmask(3).
893
+ #
894
+ # ### NOTE
895
+ #
896
+ # Asynchronous interrupts are difficult to use.
897
+ #
898
+ # If you need to communicate between threads, please consider to use another way
899
+ # such as Queue.
900
+ #
901
+ # Or use them with deep understanding about this method.
902
+ #
903
+ # ### Usage
904
+ #
905
+ # In this example, we can guard from Thread#raise exceptions.
906
+ #
907
+ # Using the `:never` TimingSymbol the RuntimeError exception will always be
908
+ # ignored in the first block of the main thread. In the second
909
+ # ::handle_interrupt block we can purposefully handle RuntimeError exceptions.
910
+ #
911
+ # th = Thread.new do
912
+ # Thread.handle_interrupt(RuntimeError => :never) {
913
+ # begin
914
+ # # You can write resource allocation code safely.
915
+ # Thread.handle_interrupt(RuntimeError => :immediate) {
916
+ # # ...
917
+ # }
918
+ # ensure
919
+ # # You can write resource deallocation code safely.
920
+ # end
921
+ # }
922
+ # end
923
+ # Thread.pass
924
+ # # ...
925
+ # th.raise "stop"
926
+ #
927
+ # While we are ignoring the RuntimeError exception, it's safe to write our
928
+ # resource allocation code. Then, the ensure block is where we can safely
929
+ # deallocate your resources.
930
+ #
931
+ # #### Stack control settings
932
+ #
933
+ # It's possible to stack multiple levels of ::handle_interrupt blocks in order
934
+ # to control more than one ExceptionClass and TimingSymbol at a time.
935
+ #
936
+ # Thread.handle_interrupt(FooError => :never) {
937
+ # Thread.handle_interrupt(BarError => :never) {
938
+ # # FooError and BarError are prohibited.
939
+ # }
940
+ # }
941
+ #
942
+ # #### Inheritance with ExceptionClass
943
+ #
944
+ # All exceptions inherited from the ExceptionClass parameter will be considered.
945
+ #
946
+ # Thread.handle_interrupt(Exception => :never) {
947
+ # # all exceptions inherited from Exception are prohibited.
948
+ # }
949
+ #
950
+ # For handling all interrupts, use `Object` and not `Exception` as the
951
+ # ExceptionClass, as kill/terminate interrupts are not handled by `Exception`.
952
+ #
953
+ def self.handle_interrupt: (untyped hash) -> untyped
954
+
955
+ # <!--
956
+ # rdoc-file=thread.c
957
+ # - thr.raise
958
+ # - thr.raise(string)
959
+ # - thr.raise(exception [, string [, array]])
960
+ # -->
961
+ # Raises an exception from the given thread. The caller does not have to be
962
+ # `thr`. See Kernel#raise for more information.
963
+ #
964
+ # Thread.abort_on_exception = true
965
+ # a = Thread.new { sleep(200) }
966
+ # a.raise("Gotcha")
967
+ #
968
+ # This will produce:
969
+ #
970
+ # prog.rb:3: Gotcha (RuntimeError)
971
+ # from prog.rb:2:in `initialize'
972
+ # from prog.rb:2:in `new'
973
+ # from prog.rb:2
974
+ #
975
+ def raise: (?String message) -> nil
976
+ | (_Exception, ?_ToS message, ?Array[Thread::Backtrace::Location] | Array[String] | nil backtrace) -> nil
977
+
978
+ # <!--
979
+ # rdoc-file=thread.c
980
+ # - Thread.kill(thread) -> thread
981
+ # -->
982
+ # Causes the given `thread` to exit, see also Thread::exit.
983
+ #
984
+ # count = 0
985
+ # a = Thread.new { loop { count += 1 } }
986
+ # sleep(0.1) #=> 0
987
+ # Thread.kill(a) #=> #<Thread:0x401b3d30 dead>
988
+ # count #=> 93947
989
+ # a.alive? #=> false
990
+ #
991
+ def self.kill: (Thread thread) -> untyped
992
+
993
+ # <!--
994
+ # rdoc-file=thread.c
995
+ # - Thread.list -> array
996
+ # -->
997
+ # Returns an array of Thread objects for all threads that are either runnable or
998
+ # stopped.
999
+ #
1000
+ # Thread.new { sleep(200) }
1001
+ # Thread.new { 1000000.times {|i| i*i } }
1002
+ # Thread.new { Thread.stop }
1003
+ # Thread.list.each {|t| p t}
1004
+ #
1005
+ # This will produce:
1006
+ #
1007
+ # #<Thread:0x401b3e84 sleep>
1008
+ # #<Thread:0x401b3f38 run>
1009
+ # #<Thread:0x401b3fb0 sleep>
1010
+ # #<Thread:0x401bdf4c run>
1011
+ #
1012
+ def self.list: () -> untyped
1013
+
1014
+ # <!--
1015
+ # rdoc-file=thread.c
1016
+ # - Thread.pass -> nil
1017
+ # -->
1018
+ # Give the thread scheduler a hint to pass execution to another thread. A
1019
+ # running thread may or may not switch, it depends on OS and processor.
1020
+ #
1021
+ def self.pass: () -> untyped
1022
+
1023
+ # <!--
1024
+ # rdoc-file=thread.c
1025
+ # - Thread.pending_interrupt?(error = nil) -> true/false
1026
+ # -->
1027
+ # Returns whether or not the asynchronous queue is empty.
1028
+ #
1029
+ # Since Thread::handle_interrupt can be used to defer asynchronous events, this
1030
+ # method can be used to determine if there are any deferred events.
1031
+ #
1032
+ # If you find this method returns true, then you may finish `:never` blocks.
1033
+ #
1034
+ # For example, the following method processes deferred asynchronous events
1035
+ # immediately.
1036
+ #
1037
+ # def Thread.kick_interrupt_immediately
1038
+ # Thread.handle_interrupt(Object => :immediate) {
1039
+ # Thread.pass
1040
+ # }
1041
+ # end
1042
+ #
1043
+ # If `error` is given, then check only for `error` type deferred events.
1044
+ #
1045
+ # ### Usage
1046
+ #
1047
+ # th = Thread.new{
1048
+ # Thread.handle_interrupt(RuntimeError => :on_blocking){
1049
+ # while true
1050
+ # ...
1051
+ # # reach safe point to invoke interrupt
1052
+ # if Thread.pending_interrupt?
1053
+ # Thread.handle_interrupt(Object => :immediate){}
1054
+ # end
1055
+ # ...
1056
+ # end
1057
+ # }
1058
+ # }
1059
+ # ...
1060
+ # th.raise # stop thread
1061
+ #
1062
+ # This example can also be written as the following, which you should use to
1063
+ # avoid asynchronous interrupts.
1064
+ #
1065
+ # flag = true
1066
+ # th = Thread.new{
1067
+ # Thread.handle_interrupt(RuntimeError => :on_blocking){
1068
+ # while true
1069
+ # ...
1070
+ # # reach safe point to invoke interrupt
1071
+ # break if flag == false
1072
+ # ...
1073
+ # end
1074
+ # }
1075
+ # }
1076
+ # ...
1077
+ # flag = false # stop thread
1078
+ #
1079
+ def self.pending_interrupt?: (*untyped args) -> bool
1080
+
1081
+ # <!--
1082
+ # rdoc-file=thread.c
1083
+ # - Thread.report_on_exception -> true or false
1084
+ # -->
1085
+ # Returns the status of the global ``report on exception'' condition.
1086
+ #
1087
+ # The default is `true` since Ruby 2.5.
1088
+ #
1089
+ # All threads created when this flag is true will report a message on $stderr if
1090
+ # an exception kills the thread.
1091
+ #
1092
+ # Thread.new { 1.times { raise } }
1093
+ #
1094
+ # will produce this output on $stderr:
1095
+ #
1096
+ # #<Thread:...> terminated with exception (report_on_exception is true):
1097
+ # Traceback (most recent call last):
1098
+ # 2: from -e:1:in `block in <main>'
1099
+ # 1: from -e:1:in `times'
1100
+ #
1101
+ # This is done to catch errors in threads early. In some cases, you might not
1102
+ # want this output. There are multiple ways to avoid the extra output:
1103
+ #
1104
+ # * If the exception is not intended, the best is to fix the cause of the
1105
+ # exception so it does not happen anymore.
1106
+ # * If the exception is intended, it might be better to rescue it closer to
1107
+ # where it is raised rather then let it kill the Thread.
1108
+ # * If it is guaranteed the Thread will be joined with Thread#join or
1109
+ # Thread#value, then it is safe to disable this report with
1110
+ # `Thread.current.report_on_exception = false` when starting the Thread.
1111
+ # However, this might handle the exception much later, or not at all if the
1112
+ # Thread is never joined due to the parent thread being blocked, etc.
1113
+ #
1114
+ # See also ::report_on_exception=.
1115
+ #
1116
+ # There is also an instance level method to set this for a specific thread, see
1117
+ # #report_on_exception=.
1118
+ #
1119
+ def self.report_on_exception: () -> untyped
1120
+
1121
+ # <!--
1122
+ # rdoc-file=thread.c
1123
+ # - Thread.report_on_exception= boolean -> true or false
1124
+ # -->
1125
+ # Returns the new state. When set to `true`, all threads created afterwards will
1126
+ # inherit the condition and report a message on $stderr if an exception kills a
1127
+ # thread:
1128
+ #
1129
+ # Thread.report_on_exception = true
1130
+ # t1 = Thread.new do
1131
+ # puts "In new thread"
1132
+ # raise "Exception from thread"
1133
+ # end
1134
+ # sleep(1)
1135
+ # puts "In the main thread"
1136
+ #
1137
+ # This will produce:
1138
+ #
1139
+ # In new thread
1140
+ # #<Thread:...prog.rb:2> terminated with exception (report_on_exception is true):
1141
+ # Traceback (most recent call last):
1142
+ # prog.rb:4:in `block in <main>': Exception from thread (RuntimeError)
1143
+ # In the main thread
1144
+ #
1145
+ # See also ::report_on_exception.
1146
+ #
1147
+ # There is also an instance level method to set this for a specific thread, see
1148
+ # #report_on_exception=.
1149
+ #
1150
+ def self.report_on_exception=: (untyped report_on_exception) -> untyped
1151
+
1152
+ # <!--
1153
+ # rdoc-file=thread.c
1154
+ # - Thread.start([args]*) {|args| block } -> thread
1155
+ # - Thread.fork([args]*) {|args| block } -> thread
1156
+ # -->
1157
+ # Basically the same as ::new. However, if class Thread is subclassed, then
1158
+ # calling `start` in that subclass will not invoke the subclass's `initialize`
1159
+ # method.
1160
+ #
1161
+ def self.start: (*untyped args) { (?) -> void } -> instance
1162
+
1163
+ # <!--
1164
+ # rdoc-file=thread.c
1165
+ # - Thread.stop -> nil
1166
+ # -->
1167
+ # Stops execution of the current thread, putting it into a ``sleep'' state, and
1168
+ # schedules execution of another thread.
1169
+ #
1170
+ # a = Thread.new { print "a"; Thread.stop; print "c" }
1171
+ # sleep 0.1 while a.status!='sleep'
1172
+ # print "b"
1173
+ # a.run
1174
+ # a.join
1175
+ # #=> "abc"
1176
+ #
1177
+ def self.stop: () -> untyped
1178
+ end
1179
+
1180
+ # <!-- rdoc-file=vm_backtrace.c -->
1181
+ # An internal representation of the backtrace. The user will never interact with
1182
+ # objects of this class directly, but class methods can be used to get backtrace
1183
+ # settings of the current session.
1184
+ #
1185
+ class Thread::Backtrace < Object
1186
+ # <!--
1187
+ # rdoc-file=vm_backtrace.c
1188
+ # - Thread::Backtrace::limit -> integer
1189
+ # -->
1190
+ # Returns maximum backtrace length set by `--backtrace-limit` command-line
1191
+ # option. The default is `-1` which means unlimited backtraces. If the value is
1192
+ # zero or positive, the error backtraces, produced by Exception#full_message,
1193
+ # are abbreviated and the extra lines are replaced by `... 3 levels... `
1194
+ #
1195
+ # $ ruby -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))"
1196
+ # - 1
1197
+ # .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError)
1198
+ # from .../lib/ruby/3.1.0/socket.rb:227:in `foreach'
1199
+ # from .../lib/ruby/3.1.0/socket.rb:632:in `tcp'
1200
+ # from .../lib/ruby/3.1.0/net/http.rb:998:in `connect'
1201
+ # from .../lib/ruby/3.1.0/net/http.rb:976:in `do_start'
1202
+ # from .../lib/ruby/3.1.0/net/http.rb:965:in `start'
1203
+ # from .../lib/ruby/3.1.0/net/http.rb:627:in `start'
1204
+ # from .../lib/ruby/3.1.0/net/http.rb:503:in `get_response'
1205
+ # from .../lib/ruby/3.1.0/net/http.rb:474:in `get'
1206
+ # .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError)
1207
+ # from .../lib/ruby/3.1.0/socket.rb:227:in `foreach'
1208
+ # from .../lib/ruby/3.1.0/socket.rb:632:in `tcp'
1209
+ # from .../lib/ruby/3.1.0/net/http.rb:998:in `connect'
1210
+ # from .../lib/ruby/3.1.0/net/http.rb:976:in `do_start'
1211
+ # from .../lib/ruby/3.1.0/net/http.rb:965:in `start'
1212
+ # from .../lib/ruby/3.1.0/net/http.rb:627:in `start'
1213
+ # from .../lib/ruby/3.1.0/net/http.rb:503:in `get_response'
1214
+ # from .../lib/ruby/3.1.0/net/http.rb:474:in `get'
1215
+ # from -e:1:in `<main>'
1216
+ #
1217
+ # $ ruby --backtrace-limit 2 -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))"
1218
+ # 2
1219
+ # .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError)
1220
+ # from .../lib/ruby/3.1.0/socket.rb:227:in `foreach'
1221
+ # from .../lib/ruby/3.1.0/socket.rb:632:in `tcp'
1222
+ # ... 7 levels...
1223
+ # .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError)
1224
+ # from .../lib/ruby/3.1.0/socket.rb:227:in `foreach'
1225
+ # from .../lib/ruby/3.1.0/socket.rb:632:in `tcp'
1226
+ # ... 7 levels...
1227
+ #
1228
+ # $ ruby --backtrace-limit 0 -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))"
1229
+ # 0
1230
+ # .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError)
1231
+ # ... 9 levels...
1232
+ # .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError)
1233
+ # ... 9 levels...
1234
+ #
1235
+ def self.limit: () -> Integer
1236
+ end
1237
+
1238
+ # <!-- rdoc-file=vm_backtrace.c -->
1239
+ # An object representation of a stack frame, initialized by
1240
+ # Kernel#caller_locations.
1241
+ #
1242
+ # For example:
1243
+ #
1244
+ # # caller_locations.rb
1245
+ # def a(skip)
1246
+ # caller_locations(skip)
1247
+ # end
1248
+ # def b(skip)
1249
+ # a(skip)
1250
+ # end
1251
+ # def c(skip)
1252
+ # b(skip)
1253
+ # end
1254
+ #
1255
+ # c(0..2).map do |call|
1256
+ # puts call.to_s
1257
+ # end
1258
+ #
1259
+ # Running `ruby caller_locations.rb` will produce:
1260
+ #
1261
+ # caller_locations.rb:2:in `a'
1262
+ # caller_locations.rb:5:in `b'
1263
+ # caller_locations.rb:8:in `c'
1264
+ #
1265
+ # Here's another example with a slightly different result:
1266
+ #
1267
+ # # foo.rb
1268
+ # class Foo
1269
+ # attr_accessor :locations
1270
+ # def initialize(skip)
1271
+ # @locations = caller_locations(skip)
1272
+ # end
1273
+ # end
1274
+ #
1275
+ # Foo.new(0..2).locations.map do |call|
1276
+ # puts call.to_s
1277
+ # end
1278
+ #
1279
+ # Now run `ruby foo.rb` and you should see:
1280
+ #
1281
+ # init.rb:4:in `initialize'
1282
+ # init.rb:8:in `new'
1283
+ # init.rb:8:in `<main>'
1284
+ #
1285
+ class Thread::Backtrace::Location
1286
+ # <!--
1287
+ # rdoc-file=vm_backtrace.c
1288
+ # - absolute_path()
1289
+ # -->
1290
+ # Returns the full file path of this frame.
1291
+ #
1292
+ # Same as #path, except that it will return absolute path even if the frame is
1293
+ # in the main script.
1294
+ #
1295
+ def absolute_path: () -> String?
1296
+
1297
+ # <!--
1298
+ # rdoc-file=vm_backtrace.c
1299
+ # - base_label()
1300
+ # -->
1301
+ # Returns the base label of this frame, which is usually equal to the label,
1302
+ # without decoration.
1303
+ #
1304
+ # Consider the following example:
1305
+ #
1306
+ # def foo
1307
+ # puts caller_locations(0).first.base_label
1308
+ #
1309
+ # 1.times do
1310
+ # puts caller_locations(0).first.base_label
1311
+ #
1312
+ # 1.times do
1313
+ # puts caller_locations(0).first.base_label
1314
+ # end
1315
+ # end
1316
+ # end
1317
+ #
1318
+ # The result of calling `foo` is this:
1319
+ #
1320
+ # foo
1321
+ # foo
1322
+ # foo
1323
+ #
1324
+ def base_label: () -> String?
1325
+
1326
+ # <!--
1327
+ # rdoc-file=vm_backtrace.c
1328
+ # - label()
1329
+ # -->
1330
+ # Returns the label of this frame.
1331
+ #
1332
+ # Usually consists of method, class, module, etc names with decoration.
1333
+ #
1334
+ # Consider the following example:
1335
+ #
1336
+ # def foo
1337
+ # puts caller_locations(0).first.label
1338
+ #
1339
+ # 1.times do
1340
+ # puts caller_locations(0).first.label
1341
+ #
1342
+ # 1.times do
1343
+ # puts caller_locations(0).first.label
1344
+ # end
1345
+ # end
1346
+ # end
1347
+ #
1348
+ # The result of calling `foo` is this:
1349
+ #
1350
+ # foo
1351
+ # block in foo
1352
+ # block (2 levels) in foo
1353
+ #
1354
+ def label: () -> String?
1355
+
1356
+ # <!--
1357
+ # rdoc-file=vm_backtrace.c
1358
+ # - lineno()
1359
+ # -->
1360
+ # Returns the line number of this frame.
1361
+ #
1362
+ # For example, using `caller_locations.rb` from Thread::Backtrace::Location
1363
+ #
1364
+ # loc = c(0..1).first
1365
+ # loc.lineno #=> 2
1366
+ #
1367
+ def lineno: () -> Integer
1368
+
1369
+ # <!--
1370
+ # rdoc-file=vm_backtrace.c
1371
+ # - path()
1372
+ # -->
1373
+ # Returns the file name of this frame. This will generally be an absolute path,
1374
+ # unless the frame is in the main script, in which case it will be the script
1375
+ # location passed on the command line.
1376
+ #
1377
+ # For example, using `caller_locations.rb` from Thread::Backtrace::Location
1378
+ #
1379
+ # loc = c(0..1).first
1380
+ # loc.path #=> caller_locations.rb
1381
+ #
1382
+ def path: () -> String?
1383
+ end
1384
+
1385
+ # <!-- rdoc-file=thread_sync.c -->
1386
+ # ConditionVariable objects augment class Mutex. Using condition variables, it
1387
+ # is possible to suspend while in the middle of a critical section until a
1388
+ # resource becomes available.
1389
+ #
1390
+ # Example:
1391
+ #
1392
+ # mutex = Thread::Mutex.new
1393
+ # resource = Thread::ConditionVariable.new
1394
+ #
1395
+ # a = Thread.new {
1396
+ # mutex.synchronize {
1397
+ # # Thread 'a' now needs the resource
1398
+ # resource.wait(mutex)
1399
+ # # 'a' can now have the resource
1400
+ # }
1401
+ # }
1402
+ #
1403
+ # b = Thread.new {
1404
+ # mutex.synchronize {
1405
+ # # Thread 'b' has finished using the resource
1406
+ # resource.signal
1407
+ # }
1408
+ # }
1409
+ #
1410
+ class Thread::ConditionVariable < Object
1411
+ # <!--
1412
+ # rdoc-file=thread_sync.c
1413
+ # - broadcast()
1414
+ # -->
1415
+ # Wakes up all threads waiting for this lock.
1416
+ #
1417
+ def broadcast: () -> self
1418
+
1419
+ # <!--
1420
+ # rdoc-file=thread_sync.c
1421
+ # - signal()
1422
+ # -->
1423
+ # Wakes up the first thread in line waiting for this lock.
1424
+ #
1425
+ def signal: () -> self
1426
+
1427
+ # <!--
1428
+ # rdoc-file=thread_sync.c
1429
+ # - wait(mutex, timeout=nil)
1430
+ # -->
1431
+ # Releases the lock held in `mutex` and waits; reacquires the lock on wakeup.
1432
+ #
1433
+ # If `timeout` is given, this method returns after `timeout` seconds passed,
1434
+ # even if no other thread doesn't signal.
1435
+ #
1436
+ # Returns the slept result on `mutex`.
1437
+ #
1438
+ def wait: (Thread::Mutex mutex, ?Time::_Timeout? timeout) -> Integer?
1439
+ end
1440
+
1441
+ # <!-- rdoc-file=thread_sync.c -->
1442
+ # Thread::Mutex implements a simple semaphore that can be used to coordinate
1443
+ # access to shared data from multiple concurrent threads.
1444
+ #
1445
+ # Example:
1446
+ #
1447
+ # semaphore = Thread::Mutex.new
1448
+ #
1449
+ # a = Thread.new {
1450
+ # semaphore.synchronize {
1451
+ # # access shared resource
1452
+ # }
1453
+ # }
1454
+ #
1455
+ # b = Thread.new {
1456
+ # semaphore.synchronize {
1457
+ # # access shared resource
1458
+ # }
1459
+ # }
1460
+ #
1461
+ class Thread::Mutex < Object
1462
+ # <!--
1463
+ # rdoc-file=thread_sync.c
1464
+ # - mutex.lock -> self
1465
+ # -->
1466
+ # Attempts to grab the lock and waits if it isn't available. Raises
1467
+ # `ThreadError` if `mutex` was locked by the current thread.
1468
+ #
1469
+ def lock: () -> self
1470
+
1471
+ # <!--
1472
+ # rdoc-file=thread_sync.c
1473
+ # - mutex.locked? -> true or false
1474
+ # -->
1475
+ # Returns `true` if this lock is currently held by some thread.
1476
+ #
1477
+ def locked?: () -> bool
1478
+
1479
+ # <!--
1480
+ # rdoc-file=thread_sync.c
1481
+ # - mutex.owned? -> true or false
1482
+ # -->
1483
+ # Returns `true` if this lock is currently held by current thread.
1484
+ #
1485
+ def owned?: () -> bool
1486
+
1487
+ # <!--
1488
+ # rdoc-file=thread_sync.c
1489
+ # - mutex.synchronize { ... } -> result of the block
1490
+ # -->
1491
+ # Obtains a lock, runs the block, and releases the lock when the block
1492
+ # completes. See the example under Thread::Mutex.
1493
+ #
1494
+ def synchronize: [X] () { () -> X } -> X
1495
+
1496
+ # <!--
1497
+ # rdoc-file=thread_sync.c
1498
+ # - mutex.try_lock -> true or false
1499
+ # -->
1500
+ # Attempts to obtain the lock and returns immediately. Returns `true` if the
1501
+ # lock was granted.
1502
+ #
1503
+ def try_lock: () -> bool
1504
+
1505
+ # <!--
1506
+ # rdoc-file=thread_sync.c
1507
+ # - mutex.unlock -> self
1508
+ # -->
1509
+ # Releases the lock. Raises `ThreadError` if `mutex` wasn't locked by the
1510
+ # current thread.
1511
+ #
1512
+ def unlock: () -> self
1513
+ end
1514
+
1515
+ # <!-- rdoc-file=thread_sync.c -->
1516
+ # The Thread::Queue class implements multi-producer, multi-consumer queues. It
1517
+ # is especially useful in threaded programming when information must be
1518
+ # exchanged safely between multiple threads. The Thread::Queue class implements
1519
+ # all the required locking semantics.
1520
+ #
1521
+ # The class implements FIFO (first in, first out) type of queue. In a FIFO
1522
+ # queue, the first tasks added are the first retrieved.
1523
+ #
1524
+ # Example:
1525
+ #
1526
+ # queue = Thread::Queue.new
1527
+ #
1528
+ # producer = Thread.new do
1529
+ # 5.times do |i|
1530
+ # sleep rand(i) # simulate expense
1531
+ # queue << i
1532
+ # puts "#{i} produced"
1533
+ # end
1534
+ # end
1535
+ #
1536
+ # consumer = Thread.new do
1537
+ # 5.times do |i|
1538
+ # value = queue.pop
1539
+ # sleep rand(i/2) # simulate expense
1540
+ # puts "consumed #{value}"
1541
+ # end
1542
+ # end
1543
+ #
1544
+ # consumer.join
1545
+ #
1546
+ class Thread::Queue[Elem = untyped] < Object
1547
+ # <!-- rdoc-file=thread_sync.c -->
1548
+ # Pushes the given `object` to the queue.
1549
+ #
1550
+ alias << push
1551
+
1552
+ # <!--
1553
+ # rdoc-file=thread_sync.c
1554
+ # - clear()
1555
+ # -->
1556
+ # Removes all objects from the queue.
1557
+ #
1558
+ def clear: () -> void
1559
+
1560
+ # <!--
1561
+ # rdoc-file=thread_sync.c
1562
+ # - close
1563
+ # -->
1564
+ # Closes the queue. A closed queue cannot be re-opened.
1565
+ #
1566
+ # After the call to close completes, the following are true:
1567
+ #
1568
+ # * `closed?` will return true
1569
+ #
1570
+ # * `close` will be ignored.
1571
+ #
1572
+ # * calling enq/push/<< will raise a `ClosedQueueError`.
1573
+ #
1574
+ # * when `empty?` is false, calling deq/pop/shift will return an object from
1575
+ # the queue as usual.
1576
+ # * when `empty?` is true, deq(false) will not suspend the thread and will
1577
+ # return nil. deq(true) will raise a `ThreadError`.
1578
+ #
1579
+ # ClosedQueueError is inherited from StopIteration, so that you can break loop
1580
+ # block.
1581
+ #
1582
+ # Example:
1583
+ #
1584
+ # q = Thread::Queue.new
1585
+ # Thread.new{
1586
+ # while e = q.deq # wait for nil to break loop
1587
+ # # ...
1588
+ # end
1589
+ # }
1590
+ # q.close
1591
+ #
1592
+ def close: () -> self
1593
+
1594
+ # <!--
1595
+ # rdoc-file=thread_sync.c
1596
+ # - closed?
1597
+ # -->
1598
+ # Returns `true` if the queue is closed.
1599
+ #
1600
+ def closed?: () -> bool
1601
+
1602
+ # <!--
1603
+ # rdoc-file=thread_sync.rb
1604
+ # - deq(non_block = false, timeout: nil)
1605
+ # -->
1606
+ #
1607
+ alias deq pop
1608
+
1609
+ # <!--
1610
+ # rdoc-file=thread_sync.c
1611
+ # - empty?
1612
+ # -->
1613
+ # Returns `true` if the queue is empty.
1614
+ #
1615
+ def empty?: () -> bool
1616
+
1617
+ # <!-- rdoc-file=thread_sync.c -->
1618
+ # Pushes the given `object` to the queue.
1619
+ #
1620
+ alias enq push
1621
+
1622
+ # <!--
1623
+ # rdoc-file=thread_sync.c
1624
+ # - freeze
1625
+ # -->
1626
+ # The queue can't be frozen, so this method raises an exception:
1627
+ # Thread::Queue.new.freeze # Raises TypeError (cannot freeze #<Thread::Queue:0x...>)
1628
+ #
1629
+ def freeze: () -> bot
1630
+
1631
+ # <!--
1632
+ # rdoc-file=thread_sync.c
1633
+ # - length
1634
+ # - size
1635
+ # -->
1636
+ # Returns the length of the queue.
1637
+ #
1638
+ def length: () -> Integer
1639
+
1640
+ # <!--
1641
+ # rdoc-file=thread_sync.c
1642
+ # - num_waiting()
1643
+ # -->
1644
+ # Returns the number of threads waiting on the queue.
1645
+ #
1646
+ def num_waiting: () -> Integer
1647
+
1648
+ # <!--
1649
+ # rdoc-file=thread_sync.rb
1650
+ # - pop(non_block=false, timeout: nil)
1651
+ # -->
1652
+ # Retrieves data from the queue.
1653
+ #
1654
+ # If the queue is empty, the calling thread is suspended until data is pushed
1655
+ # onto the queue. If `non_block` is true, the thread isn't suspended, and
1656
+ # `ThreadError` is raised.
1657
+ #
1658
+ # If `timeout` seconds have passed and no data is available `nil` is returned.
1659
+ # If `timeout` is `0` it returns immediately.
1660
+ #
1661
+ def pop: (?boolish non_block, ?timeout: _ToF?) -> Elem?
1662
+
1663
+ # <!--
1664
+ # rdoc-file=thread_sync.c
1665
+ # - push(object)
1666
+ # - enq(object)
1667
+ # - <<(object)
1668
+ # -->
1669
+ # Pushes the given `object` to the queue.
1670
+ #
1671
+ def push: (Elem obj) -> void
1672
+
1673
+ # <!--
1674
+ # rdoc-file=thread_sync.rb
1675
+ # - shift(non_block = false, timeout: nil)
1676
+ # -->
1677
+ #
1678
+ alias shift pop
1679
+
1680
+ # <!-- rdoc-file=thread_sync.c -->
1681
+ # Returns the length of the queue.
1682
+ #
1683
+ alias size length
1684
+ end
1685
+
1686
+ # <!-- rdoc-file=thread_sync.c -->
1687
+ # This class represents queues of specified size capacity. The push operation
1688
+ # may be blocked if the capacity is full.
1689
+ #
1690
+ # See Thread::Queue for an example of how a Thread::SizedQueue works.
1691
+ #
1692
+ class Thread::SizedQueue[Elem = untyped] < Thread::Queue[Elem]
1693
+ # <!--
1694
+ # rdoc-file=thread_sync.rb
1695
+ # - <<(object, non_block = false, timeout: nil)
1696
+ # -->
1697
+ #
1698
+ alias << push
1699
+
1700
+ # <!--
1701
+ # rdoc-file=thread_sync.rb
1702
+ # - enq(object, non_block = false, timeout: nil)
1703
+ # -->
1704
+ #
1705
+ alias enq push
1706
+
1707
+ # <!--
1708
+ # rdoc-file=thread_sync.c
1709
+ # - freeze
1710
+ # -->
1711
+ # The queue can't be frozen, so this method raises an exception:
1712
+ # Thread::Queue.new.freeze # Raises TypeError (cannot freeze #<Thread::Queue:0x...>)
1713
+ #
1714
+ def freeze: () -> bot
1715
+
1716
+ # <!--
1717
+ # rdoc-file=thread_sync.c
1718
+ # - new(max)
1719
+ # -->
1720
+ # Creates a fixed-length queue with a maximum size of `max`.
1721
+ #
1722
+ def initialize: (Integer max) -> void
1723
+
1724
+ # <!--
1725
+ # rdoc-file=thread_sync.c
1726
+ # - max()
1727
+ # -->
1728
+ # Returns the maximum size of the queue.
1729
+ #
1730
+ def max: () -> Integer
1731
+
1732
+ # <!--
1733
+ # rdoc-file=thread_sync.c
1734
+ # - max=(number)
1735
+ # -->
1736
+ # Sets the maximum size of the queue to the given `number`.
1737
+ #
1738
+ def max=: (Integer max) -> void
1739
+
1740
+ # <!--
1741
+ # rdoc-file=thread_sync.rb
1742
+ # - push(object, non_block=false, timeout: nil)
1743
+ # - enq(object, non_block=false, timeout: nil)
1744
+ # - <<(object)
1745
+ # -->
1746
+ # Pushes `object` to the queue.
1747
+ #
1748
+ # If there is no space left in the queue, waits until space becomes available,
1749
+ # unless `non_block` is true. If `non_block` is true, the thread isn't
1750
+ # suspended, and `ThreadError` is raised.
1751
+ #
1752
+ # If `timeout` seconds have passed and no space is available `nil` is returned.
1753
+ # If `timeout` is `0` it returns immediately. Otherwise it returns `self`.
1754
+ #
1755
+ def push: (Elem obj, ?boolish non_block) -> void
1756
+ | (Elem obj, timeout: _ToF?) -> self?
1757
+ end
1758
+
1759
+ class ConditionVariable = Thread::ConditionVariable
1760
+
1761
+ class Mutex = Thread::Mutex
1762
+
1763
+ class Queue = Thread::Queue
1764
+
1765
+ class SizedQueue = Thread::SizedQueue