Skip to content

Commit 532b924

Browse files
committed
Initialize ractor thgroup in thread_do_start_proc
Followup: #13013
1 parent 5e421ce commit 532b924

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

thread.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,8 @@ thread_do_start_proc(rb_thread_t *th)
576576

577577
if (th->invoke_type == thread_invoke_type_ractor_proc) {
578578
VALUE self = rb_ractor_self(th->ractor);
579+
th->thgroup = th->ractor->thgroup_default = rb_obj_alloc(cThGroup);
580+
579581
VM_ASSERT(FIXNUM_P(args));
580582
args_len = FIX2INT(args);
581583
args_ptr = ALLOCA_N(VALUE, args_len);
@@ -796,7 +798,6 @@ struct thread_create_params {
796798
// for normal proc thread
797799
VALUE args;
798800
VALUE proc;
799-
VALUE group;
800801

801802
// for ractor
802803
rb_ractor_t *g;
@@ -855,13 +856,7 @@ thread_create_core(VALUE thval, struct thread_create_params *params)
855856
}
856857

857858
th->priority = current_th->priority;
858-
859-
if (params->group) {
860-
th->thgroup = params->group;
861-
}
862-
else {
863-
th->thgroup = current_th->thgroup;
864-
}
859+
th->thgroup = current_th->thgroup;
865860

866861
th->pending_interrupt_queue = rb_ary_hidden_new(0);
867862
th->pending_interrupt_queue_checked = 0;
@@ -1001,19 +996,12 @@ rb_thread_create(VALUE (*fn)(void *), void *arg)
1001996
VALUE
1002997
rb_thread_create_ractor(rb_ractor_t *r, VALUE args, VALUE proc)
1003998
{
1004-
VALUE thgroup = r->thgroup_default = rb_obj_alloc(cThGroup);
1005-
#if RACTOR_CHECK_MODE > 0
1006-
rb_ractor_setup_belonging_to(thgroup, r->pub.id);
1007-
#endif
1008-
1009999
struct thread_create_params params = {
10101000
.type = thread_invoke_type_ractor_proc,
10111001
.g = r,
1012-
.group = thgroup,
10131002
.args = args,
10141003
.proc = proc,
10151004
};
1016-
RB_GC_GUARD(thgroup);
10171005
return thread_create_core(rb_thread_alloc(rb_cThread), &params);;
10181006
}
10191007

0 commit comments

Comments
 (0)