Project

General

Profile

Actions

Bug #17513

open

Methods of shareable objects and UnboundMethods should be shareable

Added by marcandre (Marc-Andre Lafortune) 7 months ago. Updated 7 months ago.

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

Description

class Foo
  def foo
  end
end

f = Foo.new.freeze
Ractor.shareable?(f) # => true
Ractor.make_shareable(f.method(:foo).to_proc) # => Proc, ok
Ractor.make_shareable(f.method(:foo)) # => Ractor::Error, expected Method
Ractor.make_shareable(Foo.instance_method(:foo)) # => Ractor::Error, expected UnboundMethod

Updated by Eregon (Benoit Daloze) 7 months ago

Methods can be defined via define_method { capture_state } and so rely on mutable state, so I guess this is only OK for def methods.

Updated by marcandre (Marc-Andre Lafortune) 7 months ago

Agreed, some methods can not be made shareable 👍.

Actions

Also available in: Atom PDF