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

ruby-changes:65405

From: Nobuyoshi <ko1@a...>
Date: Sun, 7 Mar 2021 09:54:52 +0900 (JST)
Subject: [ruby-changes:65405] f6d5de8f33 (master): [ruby/io-wait] Declare as Ractor-safe

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

From f6d5de8f33fe715d939e3e77b8ef73d88bcd6c9f Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Fri, 5 Mar 2021 17:40:39 +0900
Subject: [ruby/io-wait] Declare as Ractor-safe

Fixes https://bugs.ruby-lang.org/issues/17659

https://github.com/ruby/io-wait/commit/ba338b4764
---
 ext/io/wait/wait.c          |  4 ++++
 test/io/wait/test_ractor.rb | 22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 test/io/wait/test_ractor.rb

diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c
index 5c1a704..512e4f6 100644
--- a/ext/io/wait/wait.c
+++ b/ext/io/wait/wait.c
@@ -273,6 +273,10 @@ io_wait(int argc, VALUE *argv, VALUE io) https://github.com/ruby/ruby/blob/trunk/ext/io/wait/wait.c#L273
 void
 Init_wait(void)
 {
+#ifdef HAVE_RB_EXT_RACTOR_SAFE
+    RB_EXT_RACTOR_SAFE(true);
+#endif
+
     rb_define_method(rb_cIO, "nread", io_nread, 0);
     rb_define_method(rb_cIO, "ready?", io_ready_p, 0);
 
diff --git a/test/io/wait/test_ractor.rb b/test/io/wait/test_ractor.rb
new file mode 100644
index 0000000..3d286af
--- /dev/null
+++ b/test/io/wait/test_ractor.rb
@@ -0,0 +1,22 @@ https://github.com/ruby/ruby/blob/trunk/test/io/wait/test_ractor.rb#L1
+# frozen_string_literal: true
+require 'test/unit'
+require 'rbconfig'
+require 'io/wait'
+
+class TestIOWaitInRactor < Test::Unit::TestCase
+  def setup
+    omit unless defined? Ractor
+  end
+
+  def test_ractor
+    ext = "/io/wait.#{RbConfig::CONFIG['DLEXT']}"
+    path = $".find {|path| path.end_with?(ext)}
+    assert_in_out_err(%W[-r#{path}], <<-"end;", ["true"], [])
+      $VERBOSE = nil
+      r = Ractor.new do
+        $stdout.equal?($stdout.wait_writable)
+      end
+      puts r.take
+    end;
+  end
+end
-- 
cgit v1.1


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

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