summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2025-03-31 10:34:46 +0200
committerJean Boussier <jean.boussier@gmail.com>2025-03-31 11:14:34 +0200
commit532b9246d3819b2a309992a20ff031f91ac3e5db (patch)
treedd8b43214d2a44312b81aa7019b0775fe40bafac
parent5e421ce8d949a4f92568db359be0d188b66e58ca (diff)
Initialize ractor thgroup in `thread_do_start_proc`
Followup: https://github.com/ruby/ruby/pull/13013
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13016
-rw-r--r--thread.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/thread.c b/thread.c
index e82a54414d..661ee977a9 100644
--- a/thread.c
+++ b/thread.c
@@ -576,6 +576,8 @@ thread_do_start_proc(rb_thread_t *th)
if (th->invoke_type == thread_invoke_type_ractor_proc) {
VALUE self = rb_ractor_self(th->ractor);
+ th->thgroup = th->ractor->thgroup_default = rb_obj_alloc(cThGroup);
+
VM_ASSERT(FIXNUM_P(args));
args_len = FIX2INT(args);
args_ptr = ALLOCA_N(VALUE, args_len);
@@ -796,7 +798,6 @@ struct thread_create_params {
// for normal proc thread
VALUE args;
VALUE proc;
- VALUE group;
// for ractor
rb_ractor_t *g;
@@ -855,13 +856,7 @@ thread_create_core(VALUE thval, struct thread_create_params *params)
}
th->priority = current_th->priority;
-
- if (params->group) {
- th->thgroup = params->group;
- }
- else {
- th->thgroup = current_th->thgroup;
- }
+ th->thgroup = current_th->thgroup;
th->pending_interrupt_queue = rb_ary_hidden_new(0);
th->pending_interrupt_queue_checked = 0;
@@ -1001,19 +996,12 @@ rb_thread_create(VALUE (*fn)(void *), void *arg)
VALUE
rb_thread_create_ractor(rb_ractor_t *r, VALUE args, VALUE proc)
{
- VALUE thgroup = r->thgroup_default = rb_obj_alloc(cThGroup);
-#if RACTOR_CHECK_MODE > 0
- rb_ractor_setup_belonging_to(thgroup, r->pub.id);
-#endif
-
struct thread_create_params params = {
.type = thread_invoke_type_ractor_proc,
.g = r,
- .group = thgroup,
.args = args,
.proc = proc,
};
- RB_GC_GUARD(thgroup);
return thread_create_core(rb_thread_alloc(rb_cThread), &params);;
}