Project

General

Profile

Feature #17286

`Ractor.new` should accept `move: true`

Added by marcandre (Marc-Andre Lafortune) about 1 month ago. Updated 22 days ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:100551]

Description

Another surprise when writing my backport is that Ractor.new does not accept move: keyword argument.

Ractor.new(val, move: true) { |data| ... }
# equivalent to
Ractor.new { data = Ractor.receive; ... }.tap { |r| r.send(val, move: true) }

Updated by ko1 (Koichi Sasada) about 1 month ago

I'm also thinking about the same feature, and the problem is, maybe we should choose move or copy on each parameters:

Ractor.new io,  # want to move
           str  # want to copy
do |io, str|
  io.puts str
end

and I have no good idea about it.

Ractor.new Ractor.move(io), str do...

is one idea (wrap with special object for passing argument), but not sure it is the best....

Updated by marcandre (Marc-Andre Lafortune) 22 days ago

I'd say let's start with a simple version and see what use-cases come up.

Seems already possible to mix and match anyways... Open the Ractor with one mode and yield the other parameters using the other mode.

Also available in: Atom PDF