Skip to content

Commit 076c95e

Browse files
committed
Delete Ractor.receive_if
1 parent 2ae84a6 commit 076c95e

File tree

2 files changed

+1
-71
lines changed

2 files changed

+1
-71
lines changed

core/ractor.rbs

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -350,68 +350,6 @@ class Ractor
350350
#
351351
def self.receive: () -> untyped
352352

353-
# <!--
354-
# rdoc-file=ractor.rb
355-
# - Ractor.receive_if {|msg| block } -> msg
356-
# -->
357-
# Receive only a specific message.
358-
#
359-
# Instead of Ractor.receive, Ractor.receive_if can be given a pattern (or any
360-
# filter) in a block and you can choose the messages to accept that are
361-
# available in your ractor's incoming queue.
362-
#
363-
# r = Ractor.new do
364-
# p Ractor.receive_if{|msg| msg.match?(/foo/)} #=> "foo3"
365-
# p Ractor.receive_if{|msg| msg.match?(/bar/)} #=> "bar1"
366-
# p Ractor.receive_if{|msg| msg.match?(/baz/)} #=> "baz2"
367-
# end
368-
# r << "bar1"
369-
# r << "baz2"
370-
# r << "foo3"
371-
# r.take
372-
#
373-
# This will output:
374-
#
375-
# foo3
376-
# bar1
377-
# baz2
378-
#
379-
# If the block returns a truthy value, the message is removed from the incoming
380-
# queue and returned. Otherwise, the message remains in the incoming queue and
381-
# the next messages are checked by the given block.
382-
#
383-
# If there are no messages left in the incoming queue, the method will block
384-
# until new messages arrive.
385-
#
386-
# If the block is escaped by break/return/exception/throw, the message is
387-
# removed from the incoming queue as if a truthy value had been returned.
388-
#
389-
# r = Ractor.new do
390-
# val = Ractor.receive_if{|msg| msg.is_a?(Array)}
391-
# puts "Received successfully: #{val}"
392-
# end
393-
#
394-
# r.send(1)
395-
# r.send('test')
396-
# wait
397-
# puts "2 non-matching sent, nothing received"
398-
# r.send([1, 2, 3])
399-
# wait
400-
#
401-
# Prints:
402-
#
403-
# 2 non-matching sent, nothing received
404-
# Received successfully: [1, 2, 3]
405-
#
406-
# Note that you can not call receive/receive_if in the given block recursively.
407-
# You should not do any tasks in the block other than message filtration.
408-
#
409-
# Ractor.current << true
410-
# Ractor.receive_if{|msg| Ractor.receive}
411-
# #=> `receive': can not call receive/receive_if recursively (Ractor::Error)
412-
#
413-
def self.receive_if: () { (untyped) -> boolish } -> untyped
414-
415353
# <!--
416354
# rdoc-file=ractor.rb
417355
# - recv()

test/stdlib/Ractor_test.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,6 @@ def test_recv
7373
Ractor, :recv
7474
end
7575

76-
def test_receive_if
77-
omit "Ractor.receive_if is not implemented" if RUBY_VERSION >= "3.5"
78-
79-
Ractor.current.send 42
80-
assert_send_type "() { (Integer) -> bool } -> Integer",
81-
Ractor, :receive_if do |n| n == 42 end
82-
end
83-
8476
def test_select
8577
omit "Ractor#yield is not implemented" if RUBY_VERSION >= "3.5"
8678

@@ -160,7 +152,7 @@ def test_aset
160152

161153
def test_close_incoming
162154
omit "Ractor#close_incoming is not implemented" if RUBY_VERSION >= "3.5"
163-
155+
164156
r = Ractor.new {}
165157
assert_send_type "() -> bool",
166158
r, :close_incoming

0 commit comments

Comments
 (0)