Make it clear the first field of join_arg is the waiting thread

* And not some list of sort.
This commit is contained in:
Benoit Daloze 2020-09-21 15:58:08 +02:00
parent c19bcf38eb
commit 0fa1c82bfc

View File

@ -1119,7 +1119,7 @@ rb_thread_create_ractor(rb_ractor_t *g, VALUE args, VALUE proc)
struct join_arg { struct join_arg {
struct rb_waiting_list *waiting_list; struct rb_waiting_list *waiter;
rb_thread_t *target; rb_thread_t *target;
VALUE timeout; VALUE timeout;
}; };
@ -1134,7 +1134,7 @@ remove_from_join_list(VALUE arg)
struct rb_waiting_list **join_list = &target_thread->join_list; struct rb_waiting_list **join_list = &target_thread->join_list;
while (*join_list) { while (*join_list) {
if (*join_list == p->waiting_list) { if (*join_list == p->waiter) {
*join_list = (*join_list)->next; *join_list = (*join_list)->next;
break; break;
} }
@ -1152,7 +1152,7 @@ static VALUE
thread_join_sleep(VALUE arg) thread_join_sleep(VALUE arg)
{ {
struct join_arg *p = (struct join_arg *)arg; struct join_arg *p = (struct join_arg *)arg;
rb_thread_t *target_th = p->target, *th = p->waiting_list->thread; rb_thread_t *target_th = p->target, *th = p->waiter->thread;
rb_hrtime_t end = 0, rel = 0, *limit = 0; rb_hrtime_t end = 0, rel = 0, *limit = 0;
/* /*
@ -1220,14 +1220,14 @@ thread_join(rb_thread_t *target_th, VALUE timeout)
thread_id_str(target_th), thread_status_name(target_th, TRUE)); thread_id_str(target_th), thread_status_name(target_th, TRUE));
if (target_th->status != THREAD_KILLED) { if (target_th->status != THREAD_KILLED) {
struct rb_waiting_list waiting_list; struct rb_waiting_list waiter;
waiting_list.next = target_th->join_list; waiter.next = target_th->join_list;
waiting_list.thread = th; waiter.thread = th;
waiting_list.fiber = fiber; waiter.fiber = fiber;
target_th->join_list = &waiting_list; target_th->join_list = &waiter;
struct join_arg arg; struct join_arg arg;
arg.waiting_list = &waiting_list; arg.waiter = &waiter;
arg.target = target_th; arg.target = target_th;
arg.timeout = timeout; arg.timeout = timeout;