summaryrefslogtreecommitdiff
path: root/ext/json/generator
diff options
context:
space:
mode:
authorKenta Murata <mrkn@mrkn.jp>2020-12-21 15:57:42 +0900
committerKenta Murata <mrkn@mrkn.jp>2020-12-21 22:10:43 +0900
commit14d7d1df25bbefadfc385042d541b4afc31e4c1b (patch)
tree4177058f76232748572fd6cf246044f79ae5f35d /ext/json/generator
parent4c2e7f26bda8df087a66e546744de0d0d467ea7c (diff)
[json] Make json Ractor safe
Diffstat (limited to 'ext/json/generator')
-rw-r--r--ext/json/generator/generator.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c
index 2e802c8ea40..407c1af4a61 100644
--- a/ext/json/generator/generator.c
+++ b/ext/json/generator/generator.c
@@ -619,13 +619,18 @@ static size_t State_memsize(const void *ptr)
return size;
}
+#ifndef HAVE_RB_EXT_RACTOR_SAFE
+# undef RUBY_TYPED_FROZEN_SHAREABLE
+# define RUBY_TYPED_FROZEN_SHAREABLE 0
+#endif
+
#ifdef NEW_TYPEDDATA_WRAPPER
static const rb_data_type_t JSON_Generator_State_type = {
"JSON/Generator/State",
{NULL, State_free, State_memsize,},
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
0, 0,
- RUBY_TYPED_FREE_IMMEDIATELY,
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
#endif
};
#endif
@@ -1497,6 +1502,10 @@ static VALUE cState_buffer_initial_length_set(VALUE self, VALUE buffer_initial_l
*/
void Init_generator(void)
{
+#ifdef HAVE_RB_EXT_RACTOR_SAFE
+ rb_ext_ractor_safe(true);
+#endif
+
#undef rb_intern
rb_require("json/common");