Skip to content

Conversation

@rm155
Copy link

@rm155 rm155 commented Aug 18, 2021

This change lets Delegate avoid using shared data, and it makes sure that methods are defined using shareable Procs. In this way, Delegate's ability to be used within Ractors is increased.

end

KERNEL_RESPOND_TO = ::Kernel.instance_method(:respond_to?)
private_constant :KERNEL_RESPOND_TO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be enough to Ractor.make_shareable(KERNEL_RESPOND_TO) here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that unbound methods can't be made shareable right now. When I use make_shareable on KERNEL_RESPOND_TO, I get an error. So I think a workaround is needed for now.

Copy link
Member

@eregon eregon Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah indeed:

irb(main):001:0> KERNEL_RESPOND_TO = ::Kernel.instance_method(:respond_to?)
=> #<UnboundMethod: Kernel#respond_to?(*)>
irb(main):002:0> Ractor.make_shareable KERNEL_RESPOND_TO
<internal:ractor>:816:in `make_shareable': can not make shareable object for #<UnboundMethod: Kernel#respond_to?(*)> (Ractor::Error)
        from (irb):2:in `<main>'                                              
        from /home/eregon/.rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
        from /home/eregon/.rubies/ruby-3.1.2/bin/irb:25:in `load'             
        from /home/eregon/.rubies/ruby-3.1.2/bin/irb:25:in `<main>'     

I think it's worth reporting to https://bugs.ruby-lang.org/, could you do that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @ko1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants