rbs 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +5 -0
- data/CHANGELOG.md +23 -0
- data/README.md +6 -1
- data/core/array.rbs +2866 -1086
- data/core/basic_object.rbs +150 -30
- data/core/binding.rbs +33 -0
- data/core/builtin.rbs +4 -4
- data/core/class.rbs +43 -5
- data/core/comparable.rbs +57 -0
- data/core/complex.rbs +170 -4
- data/core/constants.rbs +51 -0
- data/core/deprecated.rbs +7 -0
- data/core/dir.rbs +305 -20
- data/core/encoding.rbs +472 -77
- data/core/enumerable.rbs +2173 -234
- data/core/enumerator.rbs +448 -182
- data/core/env.rbs +448 -1
- data/core/errno.rbs +1 -10
- data/core/errors.rbs +152 -2
- data/core/exception.rbs +201 -127
- data/core/false_class.rbs +27 -0
- data/core/fiber.rbs +118 -37
- data/core/fiber_error.rbs +8 -9
- data/core/file.rbs +1059 -139
- data/core/file_test.rbs +287 -32
- data/core/float.rbs +776 -300
- data/core/gc.rbs +185 -34
- data/core/global_variables.rbs +5 -1
- data/core/hash.rbs +1582 -649
- data/core/integer.rbs +974 -204
- data/core/io/buffer.rbs +710 -0
- data/core/io/wait.rbs +29 -8
- data/core/io.rbs +2438 -417
- data/core/kernel.rbs +2315 -316
- data/core/marshal.rbs +37 -2
- data/core/match_data.rbs +123 -6
- data/core/math.rbs +126 -6
- data/core/method.rbs +226 -102
- data/core/module.rbs +421 -45
- data/core/nil_class.rbs +64 -0
- data/core/numeric.rbs +620 -142
- data/core/object.rbs +453 -81
- data/core/object_space.rbs +92 -2
- data/core/proc.rbs +482 -285
- data/core/process.rbs +443 -34
- data/core/ractor.rbs +232 -9
- data/core/random.rbs +151 -52
- data/core/range.rbs +885 -160
- data/core/rational.rbs +122 -6
- data/core/rb_config.rbs +14 -4
- data/core/refinement.rbs +44 -0
- data/core/regexp.rbs +156 -14
- data/core/ruby_vm.rbs +42 -3
- data/core/signal.rbs +78 -39
- data/core/string.rbs +2123 -567
- data/core/string_io.rbs +204 -0
- data/core/struct.rbs +283 -28
- data/core/symbol.rbs +304 -30
- data/core/thread.rbs +1288 -688
- data/core/thread_group.rbs +66 -10
- data/core/time.rbs +643 -217
- data/core/trace_point.rbs +100 -12
- data/core/true_class.rbs +24 -0
- data/core/unbound_method.rbs +73 -7
- data/core/warning.rbs +37 -12
- data/docs/CONTRIBUTING.md +40 -34
- data/docs/stdlib.md +3 -102
- data/lib/rbs/annotate/annotations.rb +197 -0
- data/lib/rbs/annotate/formatter.rb +80 -0
- data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
- data/lib/rbs/annotate/rdoc_source.rb +120 -0
- data/lib/rbs/annotate.rb +6 -0
- data/lib/rbs/cli.rb +45 -1
- data/lib/rbs/definition_builder.rb +5 -1
- data/lib/rbs/location_aux.rb +12 -0
- data/lib/rbs/prototype/rb.rb +12 -0
- data/lib/rbs/version.rb +1 -1
- data/sig/annotate/annotations.rbs +102 -0
- data/sig/annotate/formatter.rbs +24 -0
- data/sig/annotate/rdoc_annotater.rbs +82 -0
- data/sig/annotate/rdoc_source.rbs +30 -0
- data/sig/cli.rbs +2 -0
- data/sig/collection/{collections.rbs → sources.rbs} +0 -0
- data/sig/location.rbs +6 -0
- data/sig/method_types.rbs +5 -1
- data/sig/polyfill.rbs +78 -0
- data/stdlib/abbrev/0/abbrev.rbs +6 -0
- data/stdlib/abbrev/0/array.rbs +26 -0
- data/stdlib/base64/0/base64.rbs +31 -0
- data/stdlib/benchmark/0/benchmark.rbs +74 -3
- data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
- data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
- data/stdlib/cgi/0/core.rbs +59 -0
- data/stdlib/coverage/0/coverage.rbs +164 -2
- data/stdlib/csv/0/csv.rbs +2862 -398
- data/stdlib/date/0/date.rbs +483 -25
- data/stdlib/date/0/date_time.rbs +187 -12
- data/stdlib/dbm/0/dbm.rbs +152 -17
- data/stdlib/digest/0/digest.rbs +146 -0
- data/stdlib/erb/0/erb.rbs +65 -245
- data/stdlib/fiber/0/fiber.rbs +73 -91
- data/stdlib/fileutils/0/fileutils.rbs +301 -1
- data/stdlib/find/0/find.rbs +9 -0
- data/stdlib/forwardable/0/forwardable.rbs +65 -1
- data/stdlib/io-console/0/io-console.rbs +227 -15
- data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
- data/stdlib/json/0/json.rbs +1146 -144
- data/stdlib/logger/0/formatter.rbs +24 -0
- data/stdlib/logger/0/log_device.rbs +64 -0
- data/stdlib/logger/0/logger.rbs +165 -13
- data/stdlib/logger/0/period.rbs +10 -0
- data/stdlib/logger/0/severity.rbs +26 -0
- data/stdlib/monitor/0/monitor.rbs +163 -0
- data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
- data/stdlib/net-http/0/net-http.rbs +1492 -683
- data/stdlib/nkf/0/nkf.rbs +372 -0
- data/stdlib/objspace/0/objspace.rbs +149 -90
- data/stdlib/openssl/0/openssl.rbs +8108 -71
- data/stdlib/optparse/0/optparse.rbs +487 -19
- data/stdlib/pathname/0/pathname.rbs +425 -124
- data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
- data/stdlib/prime/0/integer-extension.rbs +20 -2
- data/stdlib/prime/0/prime.rbs +88 -21
- data/stdlib/pstore/0/pstore.rbs +102 -0
- data/stdlib/pty/0/pty.rbs +64 -14
- data/stdlib/resolv/0/resolv.rbs +420 -31
- data/stdlib/rubygems/0/basic_specification.rbs +4 -1
- data/stdlib/rubygems/0/config_file.rbs +33 -1
- data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
- data/stdlib/rubygems/0/installer.rbs +13 -1
- data/stdlib/rubygems/0/path_support.rbs +4 -1
- data/stdlib/rubygems/0/platform.rbs +5 -1
- data/stdlib/rubygems/0/request_set.rbs +44 -2
- data/stdlib/rubygems/0/requirement.rbs +65 -2
- data/stdlib/rubygems/0/rubygems.rbs +407 -0
- data/stdlib/rubygems/0/source_list.rbs +13 -0
- data/stdlib/rubygems/0/specification.rbs +21 -1
- data/stdlib/rubygems/0/stream_ui.rbs +3 -1
- data/stdlib/rubygems/0/uninstaller.rbs +8 -1
- data/stdlib/rubygems/0/version.rbs +60 -157
- data/stdlib/securerandom/0/securerandom.rbs +44 -0
- data/stdlib/set/0/set.rbs +420 -106
- data/stdlib/shellwords/0/shellwords.rbs +55 -77
- data/stdlib/singleton/0/singleton.rbs +20 -0
- data/stdlib/socket/0/addrinfo.rbs +210 -9
- data/stdlib/socket/0/basic_socket.rbs +103 -11
- data/stdlib/socket/0/ip_socket.rbs +31 -9
- data/stdlib/socket/0/socket.rbs +586 -38
- data/stdlib/socket/0/tcp_server.rbs +22 -2
- data/stdlib/socket/0/tcp_socket.rbs +12 -1
- data/stdlib/socket/0/udp_socket.rbs +25 -2
- data/stdlib/socket/0/unix_server.rbs +22 -2
- data/stdlib/socket/0/unix_socket.rbs +45 -5
- data/stdlib/strscan/0/string_scanner.rbs +210 -9
- data/stdlib/tempfile/0/tempfile.rbs +58 -10
- data/stdlib/time/0/time.rbs +208 -116
- data/stdlib/timeout/0/timeout.rbs +10 -0
- data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
- data/stdlib/tsort/0/cyclic.rbs +1 -0
- data/stdlib/tsort/0/interfaces.rbs +1 -0
- data/stdlib/tsort/0/tsort.rbs +42 -0
- data/stdlib/uri/0/common.rbs +57 -8
- data/stdlib/uri/0/file.rbs +55 -109
- data/stdlib/uri/0/ftp.rbs +6 -3
- data/stdlib/uri/0/generic.rbs +556 -327
- data/stdlib/uri/0/http.rbs +26 -115
- data/stdlib/uri/0/https.rbs +8 -102
- data/stdlib/uri/0/ldap.rbs +143 -137
- data/stdlib/uri/0/ldaps.rbs +8 -102
- data/stdlib/uri/0/mailto.rbs +3 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
- data/stdlib/uri/0/ws.rbs +6 -3
- data/stdlib/uri/0/wss.rbs +5 -3
- data/stdlib/yaml/0/dbm.rbs +151 -87
- data/stdlib/yaml/0/store.rbs +6 -0
- data/stdlib/zlib/0/zlib.rbs +90 -31
- metadata +17 -5
- data/lib/rbs/location.rb +0 -221
data/core/ractor.rbs
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
+
# <!-- rdoc-file=ractor.rb -->
|
1
2
|
# Ractor is a Actor-model abstraction for Ruby that provides thread-safe
|
2
3
|
# parallel execution.
|
3
4
|
#
|
4
|
-
# Ractor.new can make new Ractor and it will run in parallel.
|
5
|
+
# Ractor.new can make a new Ractor, and it will run in parallel.
|
5
6
|
#
|
6
7
|
# # The simplest ractor
|
7
8
|
# r = Ractor.new {puts "I am in Ractor!"}
|
8
|
-
# r.take # wait it to finish
|
9
|
+
# r.take # wait for it to finish
|
9
10
|
# # here "I am in Ractor!" would be printed
|
10
11
|
#
|
11
|
-
# Ractors do not share usual objects, so the
|
12
|
-
# such as data-race, race-conditions are not available on multi-ractor
|
12
|
+
# Ractors do not share usual objects, so the same kinds of thread-safety
|
13
|
+
# concerns such as data-race, race-conditions are not available on multi-ractor
|
13
14
|
# programming.
|
14
15
|
#
|
15
16
|
# To achieve this, ractors severely limit object sharing between different
|
@@ -156,7 +157,7 @@
|
|
156
157
|
# inaccessible on a moved object.
|
157
158
|
#
|
158
159
|
# Besides frozen objects, there are shareable objects. Class and Module objects
|
159
|
-
# are shareable so the Class/Module
|
160
|
+
# are shareable so the Class/Module definitions are shared between ractors.
|
160
161
|
# Ractor objects are also shareable objects. All operations for the shareable
|
161
162
|
# mutable objects are thread-safe, so the thread-safety property will be kept.
|
162
163
|
# We can not define mutable shareable objects in Ruby, but C extensions can
|
@@ -206,7 +207,7 @@
|
|
206
207
|
# # can not access instance variables of classes/modules from non-main Ractors (RuntimeError)
|
207
208
|
#
|
208
209
|
# See also the description of `# shareable_constant_value` pragma in [Comments
|
209
|
-
# syntax](rdoc-ref:
|
210
|
+
# syntax](rdoc-ref:syntax/comments.rdoc) explanation.
|
210
211
|
#
|
211
212
|
# ## Ractors vs threads
|
212
213
|
#
|
@@ -235,8 +236,13 @@
|
|
235
236
|
#
|
236
237
|
# ## Reference
|
237
238
|
#
|
238
|
-
# See [Ractor
|
239
|
+
# See [Ractor design doc](rdoc-ref:ractor.md) for more details.
|
240
|
+
#
|
239
241
|
class Ractor
|
242
|
+
# <!--
|
243
|
+
# rdoc-file=ractor.rb
|
244
|
+
# - count()
|
245
|
+
# -->
|
240
246
|
# Returns total count of Ractors currently running.
|
241
247
|
#
|
242
248
|
# Ractor.count #=> 1
|
@@ -248,16 +254,28 @@ class Ractor
|
|
248
254
|
#
|
249
255
|
def self.count: () -> Integer
|
250
256
|
|
257
|
+
# <!--
|
258
|
+
# rdoc-file=ractor.rb
|
259
|
+
# - current()
|
260
|
+
# -->
|
251
261
|
# Returns the currently executing Ractor.
|
252
262
|
#
|
253
263
|
# Ractor.current #=> #<Ractor:#1 running>
|
254
264
|
#
|
255
265
|
def self.current: () -> untyped
|
256
266
|
|
267
|
+
# <!--
|
268
|
+
# rdoc-file=ractor.rb
|
269
|
+
# - main()
|
270
|
+
# -->
|
257
271
|
# returns main ractor
|
258
272
|
#
|
259
273
|
def self.main: () -> untyped
|
260
274
|
|
275
|
+
# <!--
|
276
|
+
# rdoc-file=ractor.rb
|
277
|
+
# - Ractor.make_shareable(obj, copy: false) -> shareable_obj
|
278
|
+
# -->
|
261
279
|
# Make `obj` shareable between ractors.
|
262
280
|
#
|
263
281
|
# `obj` and all the objects it refers to will be frozen, unless they are already
|
@@ -293,6 +311,10 @@ class Ractor
|
|
293
311
|
#
|
294
312
|
def self.make_shareable: [T] (T obj, ?copy: boolish) -> T
|
295
313
|
|
314
|
+
# <!--
|
315
|
+
# rdoc-file=ractor.rb
|
316
|
+
# - Ractor.new(*args, name: nil) {|*args| block } -> ractor
|
317
|
+
# -->
|
296
318
|
# Create a new Ractor with args and a block.
|
297
319
|
#
|
298
320
|
# A block (Proc) will be isolated (can't access to outer variables). `self`
|
@@ -324,6 +346,10 @@ class Ractor
|
|
324
346
|
#
|
325
347
|
def self.new: (*untyped args, ?name: string) { (*untyped) -> untyped } -> Ractor
|
326
348
|
|
349
|
+
# <!--
|
350
|
+
# rdoc-file=ractor.rb
|
351
|
+
# - Ractor.receive -> msg
|
352
|
+
# -->
|
327
353
|
# Receive an incoming message from the current Ractor's incoming port's queue,
|
328
354
|
# which was sent there by #send.
|
329
355
|
#
|
@@ -382,6 +408,10 @@ class Ractor
|
|
382
408
|
#
|
383
409
|
def self.receive: () -> untyped
|
384
410
|
|
411
|
+
# <!--
|
412
|
+
# rdoc-file=ractor.rb
|
413
|
+
# - Ractor.receive_if {|msg| block } -> msg
|
414
|
+
# -->
|
385
415
|
# Receive only a specific message.
|
386
416
|
#
|
387
417
|
# Instead of Ractor.receive, Ractor.receive_if can provide a pattern by a block
|
@@ -404,7 +434,7 @@ class Ractor
|
|
404
434
|
# baz2
|
405
435
|
#
|
406
436
|
# If the block returns a truthy value, the message will be removed from the
|
407
|
-
# incoming queue and returned. Otherwise, the
|
437
|
+
# incoming queue and returned. Otherwise, the message remains in the incoming
|
408
438
|
# queue and the following received messages are checked by the given block.
|
409
439
|
#
|
410
440
|
# If there are no messages left in the incoming queue, the method will block
|
@@ -439,8 +469,17 @@ class Ractor
|
|
439
469
|
#
|
440
470
|
def self.receive_if: () { (untyped) -> boolish } -> untyped
|
441
471
|
|
472
|
+
# <!--
|
473
|
+
# rdoc-file=ractor.rb
|
474
|
+
# - recv()
|
475
|
+
# -->
|
476
|
+
#
|
442
477
|
alias self.recv self.receive
|
443
478
|
|
479
|
+
# <!--
|
480
|
+
# rdoc-file=ractor.rb
|
481
|
+
# - Ractor.select(*ractors, [yield_value:, move: false]) -> [ractor or symbol, obj]
|
482
|
+
# -->
|
444
483
|
# Waits for the first ractor to have something in its outgoing port, reads from
|
445
484
|
# this ractor, and returns that ractor and the object received.
|
446
485
|
#
|
@@ -488,8 +527,12 @@ class Ractor
|
|
488
527
|
# `move` boolean flag defines whether yielded value should be copied (default)
|
489
528
|
# or moved.
|
490
529
|
#
|
491
|
-
def self.select: (*Ractor ractors, ?move: boolish, ?yield_value: untyped) -> [Ractor | Symbol, untyped]
|
530
|
+
def self.select: (*Ractor ractors, ?move: boolish, ?yield_value: untyped) -> [ Ractor | Symbol, untyped ]
|
492
531
|
|
532
|
+
# <!--
|
533
|
+
# rdoc-file=ractor.rb
|
534
|
+
# - Ractor.shareable?(obj) -> true | false
|
535
|
+
# -->
|
493
536
|
# Checks if the object is shareable by ractors.
|
494
537
|
#
|
495
538
|
# Ractor.shareable?(1) #=> true -- numbers and other immutable basic values are frozen
|
@@ -501,6 +544,10 @@ class Ractor
|
|
501
544
|
#
|
502
545
|
def self.shareable?: (untyped obj) -> bool
|
503
546
|
|
547
|
+
# <!--
|
548
|
+
# rdoc-file=ractor.rb
|
549
|
+
# - Ractor.yield(msg, move: false) -> nil
|
550
|
+
# -->
|
504
551
|
# Send a message to the current ractor's outgoing port to be consumed by #take.
|
505
552
|
#
|
506
553
|
# r = Ractor.new {Ractor.yield 'Hello from ractor'}
|
@@ -539,16 +586,33 @@ class Ractor
|
|
539
586
|
|
540
587
|
public
|
541
588
|
|
589
|
+
# <!--
|
590
|
+
# rdoc-file=ractor.rb
|
591
|
+
# - <<(obj, move: false)
|
592
|
+
# -->
|
593
|
+
#
|
542
594
|
alias << send
|
543
595
|
|
596
|
+
# <!--
|
597
|
+
# rdoc-file=ractor.rb
|
598
|
+
# - [](sym)
|
599
|
+
# -->
|
544
600
|
# get a value from ractor-local storage
|
545
601
|
#
|
546
602
|
def []: (Symbol | String sym) -> untyped
|
547
603
|
|
604
|
+
# <!--
|
605
|
+
# rdoc-file=ractor.rb
|
606
|
+
# - []=(sym, val)
|
607
|
+
# -->
|
548
608
|
# set a value in ractor-local storage
|
549
609
|
#
|
550
610
|
def []=: [T] (Symbol | String sym, T val) -> T
|
551
611
|
|
612
|
+
# <!--
|
613
|
+
# rdoc-file=ractor.rb
|
614
|
+
# - ractor.close_incoming -> true | false
|
615
|
+
# -->
|
552
616
|
# Closes the incoming port and returns its previous state. All further attempts
|
553
617
|
# to Ractor.receive in the ractor, and #send to the ractor will fail with
|
554
618
|
# Ractor::ClosedError.
|
@@ -561,6 +625,10 @@ class Ractor
|
|
561
625
|
#
|
562
626
|
def close_incoming: () -> bool
|
563
627
|
|
628
|
+
# <!--
|
629
|
+
# rdoc-file=ractor.rb
|
630
|
+
# - ractor.close_outgoing -> true | false
|
631
|
+
# -->
|
564
632
|
# Closes the outgoing port and returns its previous state. All further attempts
|
565
633
|
# to Ractor.yield in the ractor, and #take from the ractor will fail with
|
566
634
|
# Ractor::ClosedError.
|
@@ -573,12 +641,25 @@ class Ractor
|
|
573
641
|
#
|
574
642
|
def close_outgoing: () -> bool
|
575
643
|
|
644
|
+
# <!--
|
645
|
+
# rdoc-file=ractor.rb
|
646
|
+
# - inspect()
|
647
|
+
# -->
|
648
|
+
#
|
576
649
|
def inspect: () -> String
|
577
650
|
|
651
|
+
# <!--
|
652
|
+
# rdoc-file=ractor.rb
|
653
|
+
# - name()
|
654
|
+
# -->
|
578
655
|
# The name set in Ractor.new, or `nil`.
|
579
656
|
#
|
580
657
|
def name: () -> String?
|
581
658
|
|
659
|
+
# <!--
|
660
|
+
# rdoc-file=ractor.rb
|
661
|
+
# - ractor.send(msg, move: false) -> self
|
662
|
+
# -->
|
582
663
|
# Send a message to a Ractor's incoming queue to be consumed by Ractor.receive.
|
583
664
|
#
|
584
665
|
# r = Ractor.new do
|
@@ -660,6 +741,10 @@ class Ractor
|
|
660
741
|
#
|
661
742
|
def send: (untyped obj, ?move: boolish) -> Ractor
|
662
743
|
|
744
|
+
# <!--
|
745
|
+
# rdoc-file=ractor.rb
|
746
|
+
# - ractor.take -> msg
|
747
|
+
# -->
|
663
748
|
# Take a message from ractor's outgoing port, which was put there by
|
664
749
|
# Ractor.yield or at ractor's finalization.
|
665
750
|
#
|
@@ -722,18 +807,71 @@ class Ractor
|
|
722
807
|
#
|
723
808
|
def take: () -> untyped
|
724
809
|
|
810
|
+
# <!--
|
811
|
+
# rdoc-file=ractor.rb
|
812
|
+
# - to_s()
|
813
|
+
# -->
|
814
|
+
#
|
725
815
|
alias to_s inspect
|
726
816
|
|
727
817
|
private
|
728
818
|
|
819
|
+
# <!--
|
820
|
+
# rdoc-file=ractor.rb
|
821
|
+
# - receive()
|
822
|
+
# -->
|
729
823
|
# same as Ractor.receive
|
730
824
|
#
|
731
825
|
def receive: () -> untyped
|
732
826
|
|
827
|
+
# <!--
|
828
|
+
# rdoc-file=ractor.rb
|
829
|
+
# - receive_if(&b)
|
830
|
+
# -->
|
831
|
+
#
|
733
832
|
def receive_if: () { (untyped) -> boolish } -> untyped
|
734
833
|
|
834
|
+
# <!--
|
835
|
+
# rdoc-file=ractor.rb
|
836
|
+
# - recv()
|
837
|
+
# -->
|
838
|
+
#
|
735
839
|
alias recv receive
|
736
840
|
|
841
|
+
# <!-- rdoc-file=ractor.c -->
|
842
|
+
# Raised when an attempt is made to send a message to a closed port, or to
|
843
|
+
# retrieve a message from a closed and empty port. Ports may be closed
|
844
|
+
# explicitly with Ractor#close_outgoing/close_incoming and are closed implicitly
|
845
|
+
# when a Ractor terminates.
|
846
|
+
#
|
847
|
+
# r = Ractor.new { sleep(500) }
|
848
|
+
# r.close_outgoing
|
849
|
+
# r.take # Ractor::ClosedError
|
850
|
+
#
|
851
|
+
# ClosedError is a descendant of StopIteration, so the closing of the ractor
|
852
|
+
# will break the loops without propagating the error:
|
853
|
+
#
|
854
|
+
# r = Ractor.new do
|
855
|
+
# loop do
|
856
|
+
# msg = receive # raises ClosedError and loop traps it
|
857
|
+
# puts "Received: #{msg}"
|
858
|
+
# end
|
859
|
+
# puts "loop exited"
|
860
|
+
# end
|
861
|
+
#
|
862
|
+
# 3.times{|i| r << i}
|
863
|
+
# r.close_incoming
|
864
|
+
# r.take
|
865
|
+
# puts "Continue successfully"
|
866
|
+
#
|
867
|
+
# This will print:
|
868
|
+
#
|
869
|
+
# Received: 0
|
870
|
+
# Received: 1
|
871
|
+
# Received: 2
|
872
|
+
# loop exited
|
873
|
+
# Continue successfully
|
874
|
+
#
|
737
875
|
class ClosedError < StopIteration
|
738
876
|
end
|
739
877
|
|
@@ -743,31 +881,116 @@ class Ractor
|
|
743
881
|
class IsolationError < Ractor::Error
|
744
882
|
end
|
745
883
|
|
884
|
+
# <!-- rdoc-file=ractor.c -->
|
885
|
+
# Raised on an attempt to access an object which was moved in Ractor#send or
|
886
|
+
# Ractor.yield.
|
887
|
+
#
|
888
|
+
# r = Ractor.new { sleep }
|
889
|
+
#
|
890
|
+
# ary = [1, 2, 3]
|
891
|
+
# r.send(ary, move: true)
|
892
|
+
# ary.inspect
|
893
|
+
# # Ractor::MovedError (can not send any methods to a moved object)
|
894
|
+
#
|
746
895
|
class MovedError < Ractor::Error
|
747
896
|
end
|
748
897
|
|
898
|
+
# <!-- rdoc-file=ractor.c -->
|
899
|
+
# A special object which replaces any value that was moved to another ractor in
|
900
|
+
# Ractor#send or Ractor.yield. Any attempt to access the object results in
|
901
|
+
# Ractor::MovedError.
|
902
|
+
#
|
903
|
+
# r = Ractor.new { receive }
|
904
|
+
#
|
905
|
+
# ary = [1, 2, 3]
|
906
|
+
# r.send(ary, move: true)
|
907
|
+
# p Ractor::MovedObject === ary
|
908
|
+
# # => true
|
909
|
+
# ary.inspect
|
910
|
+
# # Ractor::MovedError (can not send any methods to a moved object)
|
911
|
+
#
|
749
912
|
class MovedObject < BasicObject
|
750
913
|
public
|
751
914
|
|
915
|
+
# <!--
|
916
|
+
# rdoc-file=ractor.c
|
917
|
+
# - !(*args)
|
918
|
+
# -->
|
919
|
+
#
|
752
920
|
def !: (*untyped) -> untyped
|
753
921
|
|
922
|
+
# <!--
|
923
|
+
# rdoc-file=ractor.c
|
924
|
+
# - !=(*args)
|
925
|
+
# -->
|
926
|
+
#
|
754
927
|
def !=: (*untyped) -> untyped
|
755
928
|
|
929
|
+
# <!--
|
930
|
+
# rdoc-file=ractor.c
|
931
|
+
# - ==(*args)
|
932
|
+
# -->
|
933
|
+
#
|
756
934
|
def ==: (*untyped) -> untyped
|
757
935
|
|
936
|
+
# <!--
|
937
|
+
# rdoc-file=ractor.c
|
938
|
+
# - __id__(*args)
|
939
|
+
# -->
|
940
|
+
#
|
758
941
|
def __id__: (*untyped) -> untyped
|
759
942
|
|
943
|
+
# <!--
|
944
|
+
# rdoc-file=ractor.c
|
945
|
+
# - __send__(*args)
|
946
|
+
# -->
|
947
|
+
#
|
760
948
|
def __send__: (*untyped) -> untyped
|
761
949
|
|
950
|
+
# <!--
|
951
|
+
# rdoc-file=ractor.c
|
952
|
+
# - equal?(*args)
|
953
|
+
# -->
|
954
|
+
#
|
762
955
|
def equal?: (*untyped) -> untyped
|
763
956
|
|
957
|
+
# <!--
|
958
|
+
# rdoc-file=ractor.c
|
959
|
+
# - instance_eval(*args)
|
960
|
+
# -->
|
961
|
+
#
|
764
962
|
def instance_eval: (*untyped) -> untyped
|
765
963
|
|
964
|
+
# <!--
|
965
|
+
# rdoc-file=ractor.c
|
966
|
+
# - instance_exec(*args)
|
967
|
+
# -->
|
968
|
+
#
|
766
969
|
def instance_exec: (*untyped) -> untyped
|
767
970
|
|
971
|
+
# <!--
|
972
|
+
# rdoc-file=ractor.c
|
973
|
+
# - method_missing(*args)
|
974
|
+
# -->
|
975
|
+
#
|
768
976
|
def method_missing: (*untyped) -> untyped
|
769
977
|
end
|
770
978
|
|
979
|
+
# <!-- rdoc-file=ractor.c -->
|
980
|
+
# Raised on attempt to Ractor#take if there was an uncaught exception in the
|
981
|
+
# Ractor. Its `cause` will contain the original exception, and `ractor` is the
|
982
|
+
# original ractor it was raised in.
|
983
|
+
#
|
984
|
+
# r = Ractor.new { raise "Something weird happened" }
|
985
|
+
#
|
986
|
+
# begin
|
987
|
+
# r.take
|
988
|
+
# rescue => e
|
989
|
+
# p e # => #<Ractor::RemoteError: thrown by remote Ractor.>
|
990
|
+
# p e.ractor == r # => true
|
991
|
+
# p e.cause # => #<RuntimeError: Something weird happened>
|
992
|
+
# end
|
993
|
+
#
|
771
994
|
class RemoteError < Ractor::Error
|
772
995
|
public
|
773
996
|
|