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

ruby-changes:71557

From: Yusuke <ko1@a...>
Date: Wed, 30 Mar 2022 16:51:05 +0900 (JST)
Subject: [ruby-changes:71557] 23530d68cb (master): ractor.c: Add a helper function to ensure the context is a main ractor

https://git.ruby-lang.org/ruby.git/commit/?id=23530d68cb

From 23530d68cb04aed9c2f59a050523b0193ee2d0c1 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Thu, 24 Mar 2022 14:14:07 +0900
Subject: ractor.c: Add a helper function to ensure the context is a main
 ractor

---
 ractor.c      | 8 ++++++++
 ractor_core.h | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/ractor.c b/ractor.c
index f010574028..0c17d575ee 100644
--- a/ractor.c
+++ b/ractor.c
@@ -2531,6 +2531,14 @@ rb_ractor_ensure_shareable(VALUE obj, VALUE name) https://github.com/ruby/ruby/blob/trunk/ractor.c#L2531
     return obj;
 }
 
+void
+rb_ractor_ensure_main_ractor(const char *msg)
+{
+    if (!rb_ractor_main_p()) {
+        rb_raise(rb_eRactorIsolationError, "%s", msg);
+    }
+}
+
 static enum obj_traverse_iterator_result
 shareable_p_enter(VALUE obj)
 {
diff --git a/ractor_core.h b/ractor_core.h
index a3bc90febf..f0bdec212f 100644
--- a/ractor_core.h
+++ b/ractor_core.h
@@ -185,6 +185,8 @@ void rb_ractor_atfork(rb_vm_t *vm, rb_thread_t *th); https://github.com/ruby/ruby/blob/trunk/ractor_core.h#L185
 
 VALUE rb_ractor_ensure_shareable(VALUE obj, VALUE name);
 
+void rb_ractor_ensure_main_ractor(const char *msg);
+
 RUBY_SYMBOL_EXPORT_BEGIN
 bool rb_ractor_shareable_p_continue(VALUE obj);
 
-- 
cgit v1.2.1


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

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