Ruby  3.2.0dev (2022-03-30 revision 71aa43c725084ec11827330c8502acc54bf29534)
ractor.h
Go to the documentation of this file.
1 #ifndef RUBY_RACTOR_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RUBY_RACTOR_H 1
3 
14 #include "internal/dllexport.h" /* RUBY_EXTERN is here */
15 #include "internal/fl_type.h" /* FL_TEST_RAW is here */
16 #include "internal/special_consts.h" /* RB_SPECIAL_CONSTS_P is here */
17 #include "internal/stdbool.h" /* bool is here */
18 #include "internal/value.h" /* VALUE is here */
19 
22 
29  void (*mark)(void *ptr);
30 
37  void (*free)(void *ptr);
38  // TODO: update
39 };
40 
43 
45 
46 
52 
61 
70 
79 
89 void rb_ractor_stdin_set(VALUE io);
90 
100 void rb_ractor_stdout_set(VALUE io);
101 
111 void rb_ractor_stderr_set(VALUE io);
112 
120 
131 
143 
152 
162 
164 #define RB_RACTOR_LOCAL_STORAGE_TYPE_FREE (&rb_ractor_local_storage_type_free)
165 
175 
184 
193 
213 
223 
225 
226 
235 #define RB_OBJ_SHAREABLE_P(obj) FL_TEST_RAW((obj), RUBY_FL_SHAREABLE)
236 
248 static inline bool
250 {
251  bool rb_ractor_shareable_p_continue(VALUE obj);
252 
253  if (RB_SPECIAL_CONST_P(obj)) {
254  return true;
255  }
256  else if (RB_OBJ_SHAREABLE_P(obj)) {
257  return true;
258  }
259  else {
260  return rb_ractor_shareable_p_continue(obj);
261  }
262 }
263 
264 #endif /* RUBY_RACTOR_H */
dllexport.h
Tweaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:106
rb_ractor_local_storage_type::mark
void(* mark)(void *ptr)
A function to mark a ractor-local storage.
Definition: ractor.h:29
RB_SPECIAL_CONST_P
static bool RB_SPECIAL_CONST_P(VALUE obj)
Checks if the given object is of enum ruby_special_consts.
Definition: special_consts.h:260
rb_ractor_local_storage_value_newkey
rb_ractor_local_key_t rb_ractor_local_storage_value_newkey(void)
Issues a new key.
Definition: ractor.c:3112
stdbool.h
C99 shim for <stdbool.h>
rb_ractor_local_key_t
struct rb_ractor_local_key_struct * rb_ractor_local_key_t
(Opaque) struct that holds a ractor-local storage key.
Definition: ractor.h:42
rb_ractor_local_key_struct
Definition: ractor.c:3013
rb_ractor_stderr_set
void rb_ractor_stderr_set(VALUE io)
Assigns an IO to the standard error of the Ractor that is calling this function.
Definition: ractor.c:2190
rb_ractor_local_storage_value_set
void rb_ractor_local_storage_value_set(rb_ractor_local_key_t key, VALUE val)
Associates the passed value to the passed key.
Definition: ractor.c:3195
fl_type.h
Defines enum ruby_fl_type.
rb_ractor_local_storage_ptr_newkey
rb_ractor_local_key_t rb_ractor_local_storage_ptr_newkey(const struct rb_ractor_local_storage_type *type)
Extended version of rb_ractor_local_storage_value_newkey().
Definition: ractor.c:3103
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:97
rb_ractor_stdin_set
void rb_ractor_stdin_set(VALUE io)
Assigns an IO to the standard input of the Ractor that is calling this function.
Definition: ractor.c:2166
rb_ractor_stderr
VALUE rb_ractor_stderr(void)
Queries the standard error of the current Ractor that is calling this function.
Definition: ractor.c:2154
rb_ractor_shareable_p
static bool rb_ractor_shareable_p(VALUE obj)
Queries if multiple Ractors can share the passed object or not.
Definition: ractor.h:249
RB_OBJ_SHAREABLE_P
#define RB_OBJ_SHAREABLE_P(obj)
Queries if the passed object has previously classified as shareable or not.
Definition: ractor.h:235
rb_ractor_stdout
VALUE rb_ractor_stdout(void)
Queries the standard output of the current Ractor that is calling this function.
Definition: ractor.c:2142
special_consts.h
Defines enum ruby_special_consts.
rb_ractor_make_shareable_copy
VALUE rb_ractor_make_shareable_copy(VALUE obj)
Identical to rb_ractor_make_shareable(), except it returns a (deep) copy of the passed one instead of...
Definition: ractor.c:2514
rb_ractor_local_storage_value
VALUE rb_ractor_local_storage_value(rb_ractor_local_key_t key)
Queries the key.
Definition: ractor.c:3172
rb_cRactor
VALUE rb_cRactor
Ractor class.
Definition: ractor.c:21
rb_ractor_local_storage_value_lookup
bool rb_ractor_local_storage_value_lookup(rb_ractor_local_key_t key, VALUE *val)
Queries the key.
Definition: ractor.c:3184
rb_ractor_stdout_set
void rb_ractor_stdout_set(VALUE io)
Assigns an IO to the standard output of the Ractor that is calling this function.
Definition: ractor.c:2178
rb_ractor_local_storage_ptr_set
void rb_ractor_local_storage_ptr_set(rb_ractor_local_key_t key, void *ptr)
Identical to rb_ractor_local_storage_value_set() except the parameter type.
Definition: ractor.c:3213
RUBY_EXTERN
#define RUBY_EXTERN
Declaration of externally visible global variables.
Definition: dllexport.h:47
rb_ractor_stdin
VALUE rb_ractor_stdin(void)
Queries the standard input of the current Ractor that is calling this function.
Definition: ractor.c:2130
rb_ractor_local_storage_type_free
const struct rb_ractor_local_storage_type rb_ractor_local_storage_type_free
A type of ractor-local storage that destructs itself using ruby_xfree.
Definition: ractor.c:3092
rb_ractor_local_storage_type
Type that defines a ractor-local storage.
Definition: ractor.h:21
rb_ractor_make_shareable
VALUE rb_ractor_make_shareable(VALUE obj)
Destructively transforms the passed object so that multiple Ractors can share it.
Definition: ractor.c:2505
rb_ractor_local_storage_type::free
void(* free)(void *ptr)
A function to destruct a ractor-local storage.
Definition: ractor.h:37
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition: value.h:40
rb_ractor_local_storage_ptr
void * rb_ractor_local_storage_ptr(rb_ractor_local_key_t key)
Identical to rb_ractor_local_storage_value() except the return type.
Definition: ractor.c:3201
value.h
Defines VALUE and ID.
ruby::backward::cxxanyargs::type
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:56