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

ruby-changes:65463

From: Nobuyoshi <ko1@a...>
Date: Sat, 13 Mar 2021 09:12:11 +0900 (JST)
Subject: [ruby-changes:65463] 983f6d0f2a (master): Moved locking VM to an atomic operation

https://git.ruby-lang.org/ruby.git/commit/?id=983f6d0f2a

From 983f6d0f2af157ce2df9428a1701d8666877d0f5 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 7 Mar 2021 10:24:03 +0900
Subject: Moved locking VM to an atomic operation

---
 ractor.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/ractor.c b/ractor.c
index 4cb7b5a..36898db 100644
--- a/ractor.c
+++ b/ractor.c
@@ -290,7 +290,7 @@ RACTOR_PTR(VALUE self) https://github.com/ruby/ruby/blob/trunk/ractor.c#L290
     return r;
 }
 
-static uint32_t ractor_last_id;
+static rb_atomic_t ractor_last_id;
 
 #if RACTOR_CHECK_MODE > 0
 MJIT_FUNC_EXPORTED uint32_t
@@ -1399,11 +1399,7 @@ ractor_next_id(void) https://github.com/ruby/ruby/blob/trunk/ractor.c#L1399
 {
     uint32_t id;
 
-    RB_VM_LOCK();
-    {
-        id = ++ractor_last_id;
-    }
-    RB_VM_UNLOCK();
+    id = (uint32_t)(RUBY_ATOMIC_FETCH_ADD(ractor_last_id, 1) + 1);
 
     return id;
 }
-- 
cgit v1.1


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

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