Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make C-extension Ractor-safe #2024

Open
mohamedhafez opened this issue Sep 19, 2024 · 1 comment
Open

Make C-extension Ractor-safe #2024

mohamedhafez opened this issue Sep 19, 2024 · 1 comment

Comments

@mohamedhafez
Copy link

In planning ahead to the near future when TruffleRuby can run C-extensions marked with rb_ext_ractor_safe(true) in parallel, and for when Ractors are no longer just experimental, it would be great if the C-extension could be made Ractor-safe, or marked as such if it already is so! Would be happy to send in a PR in the later case.

@eregon
Copy link
Member

eregon commented Oct 1, 2024

From a quick look at

Init_rbs_extension(void)
{
rbs__init_constants();
rbs__init_location();
rbs__init_parser();
}
and the 3 callees it looks fine.

rbs/ext/rbs_extension/parser.c

Lines 2985 to 2987 in c255458

VALUE empty_array = rb_obj_freeze(rb_ary_new());
rb_gc_register_mark_object(empty_array);
EMPTY_ARRAY = empty_array;
is fine because it's an immutable/deeply-frozen object.
https://github.com/ruby/rbs/blob/master/ext/rbs_extension/constants.c are just some written-once variables (so basically constants).
And https://github.com/ruby/rbs/blob/master/ext/rbs_extension/location.c seems to have no state as well.

@mohamedhafez Could you make a PR?

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

No branches or pull requests

2 participants