]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Mark ruby bindings as ractor safe (#1283) master
authorRein Fernhout <me@levitati.ng>
Fri, 4 Apr 2025 06:21:49 +0000 (08:21 +0200)
committerGitHub <noreply@github.com>
Fri, 4 Apr 2025 06:21:49 +0000 (08:21 +0200)
Ruby has a new method for concurrency called Ractors.

For C bindings to be used inside a Ractor they need to be marked
Ractor-safe [1]:
  If an extension desires to be marked as Ractor-safe the extension
  should call rb_ext_ractor_safe(true) at the Init_ function for the
  extension, and all defined methods will be marked as Ractor-safe.

By marking them Ractor-safe ruby programs can generate graphs concurrently.

See also ruby/ruby#3824 for more information concerning this method.

[1] https://docs.ruby-lang.org/en/master/extension_rdoc.html#label-Appendix+F.+Ractor+support

CHANGES
bindings/ruby/extconf.rb
bindings/ruby/main.c

diff --git a/CHANGES b/CHANGES
index 291cac7b39e26beefd9ae8eb3a6b6c2fa0485f52..626bce79663b71c182f6ffe1999384ede3df49fc 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -3,7 +3,7 @@ RRDtool - master ...
 ====================
 Bugfixes
 --------
-
+* Mark the Ruby bindings as Ractor safe @LevitatingBusinessMan
 * Fix Compatiblity with TCL-9 @yselkowitz
 * Correctly link Ruby Bindings @LevitatingBusinessMan
 * Fix MacOS Build error (no SOCK_CLOEXEC on mac) @ensc fixes oetiker#1261
index de0171dc6d700a0c26309e0fd4120813ff16e026..0ce953e1bd4fc3424b466e49dd4e000e18da3a16 100644 (file)
@@ -19,4 +19,5 @@ ABS_TOP_SRCDIR = ENV['ABS_TOP_SRCDIR'] || '../..'
 
 dir_config("rrd", ["#{ABS_TOP_BUILDDIR}/src", "#{ABS_TOP_SRCDIR}/src"], "#{ABS_TOP_BUILDDIR}/src/.libs")
 have_library("rrd", "rrd_create")
+have_func("rb_ext_ractor_safe", "ruby.h")
 create_makefile("RRD")
index a036b7fb88b3e962baa0eba3816cde7ed49a04eb..f58f643f4c59e955a2f549966c4f1d15daf82e17 100644 (file)
@@ -371,6 +371,10 @@ VALUE rb_rrd_xport(
 void Init_RRD(
     )
 {
+    #if HAVE_RB_EXT_RACTOR_SAFE
+        rb_ext_ractor_safe(true);
+    #endif
+
     mRRD = rb_define_module("RRD");
     rb_eRRDError = rb_define_class("RRDError", rb_eStandardError);