[前][次][番号順一覧][スレッド一覧]

ruby-changes:63034

From: Benoit <ko1@a...>
Date: Mon, 21 Sep 2020 22:59:02 +0900 (JST)
Subject: [ruby-changes:63034] 0fa1c82bfc (master): Make it clear the first field of join_arg is the waiting thread

https://git.ruby-lang.org/ruby.git/commit/?id=0fa1c82bfc

From 0fa1c82bfc3c679c49df2e586183db1efbd8f62c Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Mon, 21 Sep 2020 15:58:08 +0200
Subject: Make it clear the first field of join_arg is the waiting thread

* And not some list of sort.

diff --git a/thread.c b/thread.c
index 35a35f2..d6a4f7a 100644
--- a/thread.c
+++ b/thread.c
@@ -1119,7 +1119,7 @@ rb_thread_create_ractor(rb_ractor_t *g, VALUE args, VALUE proc) https://github.com/ruby/ruby/blob/trunk/thread.c#L1119
 
 
 struct join_arg {
-    struct rb_waiting_list *waiting_list;
+    struct rb_waiting_list *waiter;
     rb_thread_t *target;
     VALUE timeout;
 };
@@ -1134,11 +1134,11 @@ remove_from_join_list(VALUE arg) https://github.com/ruby/ruby/blob/trunk/thread.c#L1134
         struct rb_waiting_list **join_list = &target_thread->join_list;
 
         while (*join_list) {
-            if (*join_list == p->waiting_list) {
+            if (*join_list == p->waiter) {
                 *join_list = (*join_list)->next;
                 break;
             }
-            
+
             join_list = &(*join_list)->next;
         }
     }
@@ -1152,7 +1152,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/thread.c#L1152
 thread_join_sleep(VALUE 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;
 
     /*
@@ -1220,14 +1220,14 @@ thread_join(rb_thread_t *target_th, VALUE timeout) https://github.com/ruby/ruby/blob/trunk/thread.c#L1220
                  thread_id_str(target_th), thread_status_name(target_th, TRUE));
 
     if (target_th->status != THREAD_KILLED) {
-        struct rb_waiting_list waiting_list;
-        waiting_list.next = target_th->join_list;
-        waiting_list.thread = th;
-        waiting_list.fiber = fiber;
-        target_th->join_list = &waiting_list;
+        struct rb_waiting_list waiter;
+        waiter.next = target_th->join_list;
+        waiter.thread = th;
+        waiter.fiber = fiber;
+        target_th->join_list = &waiter;
 
         struct join_arg arg;
-        arg.waiting_list = &waiting_list;
+        arg.waiter = &waiter;
         arg.target = target_th;
         arg.timeout = timeout;
 
@@ -1308,7 +1308,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/thread.c#L1308
 thread_join_m(int argc, VALUE *argv, VALUE self)
 {
     VALUE timeout = Qnil;
-    
+
     if (rb_check_arity(argc, 0, 1)) {
         timeout = argv[0];
     }
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]