⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.133
Server IP:
185.119.109.197
Server:
Linux managedhosting.chostar.me 5.15.0-160-generic #170-Ubuntu SMP Wed Oct 1 10:06:56 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.1.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
proc
/
self
/
root
/
usr
/
share
/
ri
/
3.0.0
/
system
/
Ractor
/
View File Name :
receive_if-c.ri
U:RDoc::AnyMethod[iI"receive_if:ETI"Ractor::receive_if;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"%Receive only a specific message.;To:RDoc::Markup::BlankLine o; ; [I"HInstead of Ractor.receive, Ractor.receive_if can provide a pattern ;TI"9by a block and you can choose the receiving message.;T@o:RDoc::Markup::Verbatim; [I"r = Ractor.new do ;TI"? p Ractor.receive_if{|msg| msg.match?(/foo/)} #=> "foo3" ;TI"? p Ractor.receive_if{|msg| msg.match?(/bar/)} #=> "bar1" ;TI"? p Ractor.receive_if{|msg| msg.match?(/baz/)} #=> "baz2" ;TI" end ;TI"r << "bar1" ;TI"r << "baz2" ;TI"r << "foo3" ;TI"r.take ;T:@format0o; ; [I"This will output:;T@o;; [I" foo3 ;TI" bar1 ;TI" baz2 ;T; 0o; ; [ I"^If the block returns a truthy value, the message will be removed from the incoming queue ;TI"and returned. ;TI"VOtherwise, the messsage remains in the incoming queue and the following received ;TI"-messages are checked by the given block.;T@o; ; [I"JIf there are no messages left in the incoming queue, the method will ;TI"%block until new messages arrive.;T@o; ; [I"ZIf the block is escaped by break/return/exception/throw, the message is removed from ;TI"?the incoming queue as if a truthy value had been returned.;T@o;; [I"r = Ractor.new do ;TI"7 val = Ractor.receive_if{|msg| msg.is_a?(Array)} ;TI", puts "Received successfully: #{val}" ;TI" end ;TI" ;TI"r.send(1) ;TI"r.send('test') ;TI" wait ;TI"2puts "2 non-matching sent, nothing received" ;TI"r.send([1, 2, 3]) ;TI" wait ;T; 0o; ; [I"Prints:;T@o;; [I"+2 non-matching sent, nothing received ;TI"&Received successfully: [1, 2, 3] ;T; 0o; ; [I"SNote that you can not call receive/receive_if in the given block recursively. ;TI"
`receive': can not call receive/receive_if recursively (Ractor::Error);T; 0: @fileI"ractor.rb;T:0@omit_headings_from_table_of_contents_below0I"-Ractor.receive_if {|msg| block } -> msg ;T0[ I" (&b);T@QFI"Ractor;TcRDoc::NormalClass00