Skip to content

Commit 0738108

Browse files
committed
Delete Ractor#take
1 parent 756c093 commit 0738108

File tree

2 files changed

+0
-76
lines changed

2 files changed

+0
-76
lines changed

core/ractor.rbs

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -447,73 +447,6 @@ class Ractor
447447
#
448448
def send: (untyped obj, ?move: boolish) -> Ractor
449449

450-
# <!--
451-
# rdoc-file=ractor.rb
452-
# - ractor.take -> msg
453-
# -->
454-
# Get a message from the ractor's outgoing port, which was put there by
455-
# Ractor.yield or at ractor's termination.
456-
#
457-
# r = Ractor.new do
458-
# Ractor.yield 'explicit yield'
459-
# 'last value'
460-
# end
461-
# puts r.take #=> 'explicit yield'
462-
# puts r.take #=> 'last value'
463-
# puts r.take # Ractor::ClosedError (The outgoing-port is already closed)
464-
#
465-
# The fact that the last value is also sent to the outgoing port means that
466-
# `take` can be used as an analog of Thread#join ("just wait until ractor
467-
# finishes"). However, it will raise if somebody has already consumed that
468-
# message.
469-
#
470-
# If the outgoing port was closed with #close_outgoing, the method will raise
471-
# Ractor::ClosedError.
472-
#
473-
# r = Ractor.new do
474-
# sleep(500)
475-
# Ractor.yield 'Hello from ractor'
476-
# end
477-
# r.close_outgoing
478-
# r.take
479-
# # Ractor::ClosedError (The outgoing-port is already closed)
480-
# # The error would be raised immediately, not when ractor will try to receive
481-
#
482-
# If an uncaught exception is raised in the Ractor, it is propagated by take as
483-
# a Ractor::RemoteError.
484-
#
485-
# r = Ractor.new {raise "Something weird happened"}
486-
#
487-
# begin
488-
# r.take
489-
# rescue => e
490-
# p e # => #<Ractor::RemoteError: thrown by remote Ractor.>
491-
# p e.ractor == r # => true
492-
# p e.cause # => #<RuntimeError: Something weird happened>
493-
# end
494-
#
495-
# Ractor::ClosedError is a descendant of StopIteration, so the termination of
496-
# the ractor will break out of any loops that receive this message without
497-
# propagating the error:
498-
#
499-
# r = Ractor.new do
500-
# 3.times {|i| Ractor.yield "message #{i}"}
501-
# "finishing"
502-
# end
503-
#
504-
# loop {puts "Received: " + r.take}
505-
# puts "Continue successfully"
506-
#
507-
# This will print:
508-
#
509-
# Received: message 0
510-
# Received: message 1
511-
# Received: message 2
512-
# Received: finishing
513-
# Continue successfully
514-
#
515-
def take: () -> untyped
516-
517450
# <!--
518451
# rdoc-file=ractor.rb
519452
# - to_s()

test/stdlib/Ractor_test.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,6 @@ def test_send
118118
r, :send, 42, move: nil
119119
end
120120

121-
def test_take
122-
omit "Ractor#take is not implemented" if RUBY_VERSION >= "3.5"
123-
124-
r = Ractor.new { 42 }
125-
126-
assert_send_type "() -> Integer",
127-
r, :take
128-
end
129-
130121
def test_to_s
131122
assert_send_type "() -> String",
132123
Ractor.current, :to_s

0 commit comments

Comments
 (0)