Project

General

Profile

Actions

Feature #17286

open

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

Added by marcandre (Marc-Andre Lafortune) about 4 years ago. Updated about 4 years ago.

Status:
Open
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 4 years 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) about 4 years 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0