D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Ractor
/
Filename :
new-c.ri
back
Copy
U:RDoc::AnyMethod[iI"new:ETI"Ractor::new;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"0Create a new \Ractor with args and a block.;To:RDoc::Markup::BlankLine o; ; [I"XThe given block (Proc) will be isolated (can't access any outer variables). +self+ ;TI"8inside the block will refer to the current \Ractor.;T@o:RDoc::Markup::Verbatim; [I"8r = Ractor.new { puts "Hi, I am #{self.inspect}" } ;TI"r.take ;TI"8# Prints "Hi, I am #<Ractor:#2 test.rb:1 running>" ;T:@format0o; ; [I"RAny +args+ passed are propagated to the block arguments by the same rules as ;TI"Zobjects sent via #send/Ractor.receive. If an argument in +args+ is not shareable, it ;TI"Cwill be copied (via deep cloning, which might be inefficient).;T@o;; [I"arg = [1, 2, 3] ;TI"0puts "Passing: #{arg} (##{arg.object_id})" ;TI")r = Ractor.new(arg) {|received_arg| ;TI"E puts "Received: #{received_arg} (##{received_arg.object_id})" ;TI"} ;TI"r.take ;TI"# Prints: ;TI"## Passing: [1, 2, 3] (#280) ;TI"$# Received: [1, 2, 3] (#300) ;T; 0o; ; [I"7Ractor's +name+ can be set for debugging purposes:;T@o;; [I"2r = Ractor.new(name: 'my ractor') {}; r.take ;TI" p r ;TI"4#=> #<Ractor:#3 my ractor test.rb:1 terminated>;T; 0: @fileI"ractor.rb;T:0@omit_headings_from_table_of_contents_below0I"=Ractor.new(*args, name: nil) {|*args| block } -> ractor ;T0[ I"(*args, name: nil, &block);T@0FI"Ractor;TcRDoc::NormalClass00