Skip to content

Make Ractor-compatible#344

Open
jhawthorn wants to merge 11 commits into
ruby:masterfrom
jhawthorn:ractors
Open

Make Ractor-compatible#344
jhawthorn wants to merge 11 commits into
ruby:masterfrom
jhawthorn:ractors

Conversation

@jhawthorn

Copy link
Copy Markdown
Member

For the most part this just involved freezing Strings or other constants. I tried to aim for the best final state rather than workarounds, so let me know if any changes are desired/anything is too aggressive ❤️. Where possible I changed to frozen_string_literal: true instead of simply freezing the required constants.

Two more significant changes are:

  • Changed FunctionsClass to use method_defined?(x, false) instead of maintaining a mutable hash. This required bumping to Ruby 2.6
  • Changed REXML::Security to use ivars instead of cvars. This module wasn't included anywhere internally so it should work the same. (Ruby 4.1+ will allow cvars to be read from Ractors so this change was only necessary for earlier/current versions, but I think it's faster and better anyways)

jhawthorn added 11 commits June 28, 2026 19:22
Previously this was using class variables, however this module isn't
included anywhere, so we might as well just use plain ivars
The @@available_functions class-variable wasn't frozen (to allow
runtime methods to be added). I should be as fast to check for
method_defined?(name, false), though this requires Ruby 2.6
Needed for method_defined?(x, false)
This fixes a FrozenError on Ruby 2.6/2.7. On Ruby 3.0+ interpolated
strings are always unfrozen
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.

1 participant