1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

ractor.c: Add a helper function to ensure the context is a main ractor

This commit is contained in:
Yusuke Endoh 2022-03-24 14:14:07 +09:00
parent a94002115b
commit 23530d68cb
Notes: git 2022-03-30 16:51:11 +09:00
2 changed files with 10 additions and 0 deletions

View file

@ -2531,6 +2531,14 @@ rb_ractor_ensure_shareable(VALUE obj, VALUE name)
return obj;
}
void
rb_ractor_ensure_main_ractor(const char *msg)
{
if (!rb_ractor_main_p()) {
rb_raise(rb_eRactorIsolationError, "%s", msg);
}
}
static enum obj_traverse_iterator_result
shareable_p_enter(VALUE obj)
{

View file

@ -185,6 +185,8 @@ void rb_ractor_atfork(rb_vm_t *vm, rb_thread_t *th);
VALUE rb_ractor_ensure_shareable(VALUE obj, VALUE name);
void rb_ractor_ensure_main_ractor(const char *msg);
RUBY_SYMBOL_EXPORT_BEGIN
bool rb_ractor_shareable_p_continue(VALUE obj);