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

ruby-changes:63009

From: Benoit <ko1@a...>
Date: Fri, 18 Sep 2020 17:43:27 +0900 (JST)
Subject: [ruby-changes:63009] 5bb5e706f1 (master): Only interrupt when there is no scheduler in sync_wakeup()

https://git.ruby-lang.org/ruby.git/commit/?id=5bb5e706f1

From 5bb5e706f1d310a467075630145d2cc277045765 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Fri, 18 Sep 2020 10:39:27 +0200
Subject: Only interrupt when there is no scheduler in sync_wakeup()

* When there is a scheduler, the Fiber that would be blocked has already
  been rescheduled and there is no point to interrupt something else.
  That blocked Fiber will be rescheduled as the next call to the scheduler
  (e.g., IO, sleep, other blocking sync).
* See discussion on https://github.com/ruby/ruby/commit/d01954632d

diff --git a/thread_sync.c b/thread_sync.c
index 41df2de..748ccbd 100644
--- a/thread_sync.c
+++ b/thread_sync.c
@@ -34,8 +34,10 @@ sync_wakeup(struct list_head *head, long max) https://github.com/ruby/ruby/blob/trunk/thread_sync.c#L34
         }
 
         if (cur->th->status != THREAD_KILLED) {
-            rb_threadptr_interrupt(cur->th);
-            cur->th->status = THREAD_RUNNABLE;
+            if (cur->th->scheduler != Qnil) {
+                rb_threadptr_interrupt(cur->th);
+                cur->th->status = THREAD_RUNNABLE;
+            }
             if (--max == 0) return;
         }
     }
-- 
cgit v0.10.2


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

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