diff options
Diffstat (limited to 'include/ruby/ractor.h')
| -rw-r--r-- | include/ruby/ractor.h | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/include/ruby/ractor.h b/include/ruby/ractor.h index 47eac038c9..8cfca21621 100644 --- a/include/ruby/ractor.h +++ b/include/ruby/ractor.h @@ -145,7 +145,7 @@ bool rb_ractor_local_storage_value_lookup(rb_ractor_local_key_t key, VALUE *val) * Associates the passed value to the passed key. * * @param[in] key A ractor-local storage key. - * @param[in] val Arbitary ruby object. + * @param[in] val Arbitrary ruby object. * @post `val` corresponds to `key` in the current Ractor. */ void rb_ractor_local_storage_value_set(rb_ractor_local_key_t key, VALUE val); @@ -217,7 +217,7 @@ VALUE rb_ractor_make_shareable(VALUE obj); * * @param[in] obj Arbitrary ruby object to duplicate. * @exception rb_eRactorError Ractors cannot share `obj` by nature. - * @return A deep copy of `obj` which is sharable among Ractors. + * @return A deep copy of `obj` which is shareable among Ractors. */ VALUE rb_ractor_make_shareable_copy(VALUE obj); @@ -241,8 +241,9 @@ RBIMPL_SYMBOL_EXPORT_END() * extremely carefully implemented to be Ractor-safe; for instance integers * have such property. This function can classify that. * - * @param[in] obj Arbitrary ruby object. - * @ + * @param[in] obj Arbitrary ruby object. + * @retval true `obj` is capable of shared across ractors. + * @retval false `obj` cannot travel across ractor boundaries. */ static inline bool rb_ractor_shareable_p(VALUE obj) @@ -260,4 +261,18 @@ rb_ractor_shareable_p(VALUE obj) } } +// TODO: optimize on interpreter core +#ifndef RB_OBJ_SET_SHAREABLE +VALUE rb_obj_set_shareable(VALUE obj); // ractor.c +#define RB_OBJ_SET_SHAREABLE(obj) rb_obj_set_shareable(obj) +#endif + +static inline VALUE +RB_OBJ_SET_FROZEN_SHAREABLE(VALUE obj) +{ + RB_OBJ_FREEZE(obj); + RB_OBJ_SET_SHAREABLE(obj); + return obj; +} + #endif /* RUBY_RACTOR_H */ |
