Ruby: include/ruby/ractor.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

ractor.h
Go to the documentation of this file.
1#ifndef RUBY_RACTOR_H
2#define RUBY_RACTOR_H 1
3
15 struct rb_ractor_local_storage_type {
16 void (*mark)(void *ptr);
17 void (*free)(void *ptr);
18 // TODO: update
19};
20
21 typedef struct rb_ractor_local_key_struct *rb_ractor_local_key_t;
22
23RUBY_SYMBOL_EXPORT_BEGIN
24 RUBY_EXTERN VALUE rb_cRactor;
25
26 VALUE rb_ractor_stdin(void);
27 VALUE rb_ractor_stdout(void);
28 VALUE rb_ractor_stderr(void);
29void rb_ractor_stdin_set(VALUE);
30void rb_ractor_stdout_set(VALUE);
31void rb_ractor_stderr_set(VALUE);
32
33 rb_ractor_local_key_t rb_ractor_local_storage_value_newkey(void);
34 VALUE rb_ractor_local_storage_value(rb_ractor_local_key_t key);
35bool rb_ractor_local_storage_value_lookup(rb_ractor_local_key_t key, VALUE *val);
36void rb_ractor_local_storage_value_set(rb_ractor_local_key_t key, VALUE val);
37
38 RUBY_EXTERN const struct rb_ractor_local_storage_type rb_ractor_local_storage_type_free;
39#define RB_RACTOR_LOCAL_STORAGE_TYPE_FREE (&rb_ractor_local_storage_type_free)
40
41 rb_ractor_local_key_t rb_ractor_local_storage_ptr_newkey(const struct rb_ractor_local_storage_type *type);
42void *rb_ractor_local_storage_ptr(rb_ractor_local_key_t key);
43void rb_ractor_local_storage_ptr_set(rb_ractor_local_key_t key, void *ptr);
44
45 VALUE rb_ractor_make_shareable(VALUE obj);
46 VALUE rb_ractor_make_shareable_copy(VALUE obj);
47
48RUBY_SYMBOL_EXPORT_END
49
50#define RB_OBJ_SHAREABLE_P(obj) FL_TEST_RAW((obj), RUBY_FL_SHAREABLE)
51
52static inline bool
53rb_ractor_shareable_p(VALUE obj)
54{
55 bool rb_ractor_shareable_p_continue(VALUE obj);
56
57 if (SPECIAL_CONST_P(obj)) {
58 return true;
59 }
60 else if (RB_OBJ_SHAREABLE_P(obj)) {
61 return true;
62 }
63 else {
64 return rb_ractor_shareable_p_continue(obj);
65 }
66}
67
68#endif /* RUBY_RACTOR_H */
ptr
struct RIMemo * ptr
Definition: debug.c:88
RUBY_EXTERN
#define RUBY_EXTERN
Definition: dllexport.h:36
key
key
Definition: openssl_missing.h:185
rb_ractor_shareable_p_continue
bool rb_ractor_shareable_p_continue(VALUE obj)
Definition: ractor.c:2550
rb_ractor_local_storage_type_free
const struct rb_ractor_local_storage_type rb_ractor_local_storage_type_free
Definition: ractor.c:3086
rb_ractor_make_shareable_copy
VALUE rb_ractor_make_shareable_copy(VALUE obj)
Definition: ractor.c:2508
rb_ractor_local_key_t
struct rb_ractor_local_key_struct * rb_ractor_local_key_t
Definition: ractor.h:21
rb_ractor_local_storage_ptr
void * rb_ractor_local_storage_ptr(rb_ractor_local_key_t key)
Definition: ractor.c:3195
rb_ractor_stdout_set
void rb_ractor_stdout_set(VALUE)
Definition: ractor.c:2172
rb_ractor_stdin_set
void rb_ractor_stdin_set(VALUE)
Definition: ractor.c:2160
rb_ractor_local_storage_ptr_set
void rb_ractor_local_storage_ptr_set(rb_ractor_local_key_t key, void *ptr)
Definition: ractor.c:3207
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)
Definition: ractor.c:3097
rb_ractor_stderr
VALUE rb_ractor_stderr(void)
Definition: ractor.c:2148
rb_cRactor
VALUE rb_cRactor
Definition: ractor.c:20
rb_ractor_stdin
VALUE rb_ractor_stdin(void)
Definition: ractor.c:2124
rb_ractor_local_storage_value_set
void rb_ractor_local_storage_value_set(rb_ractor_local_key_t key, VALUE val)
Definition: ractor.c:3189
rb_ractor_local_storage_value_lookup
bool rb_ractor_local_storage_value_lookup(rb_ractor_local_key_t key, VALUE *val)
Definition: ractor.c:3178
rb_ractor_stdout
VALUE rb_ractor_stdout(void)
Definition: ractor.c:2136
RB_OBJ_SHAREABLE_P
#define RB_OBJ_SHAREABLE_P(obj)
Definition: ractor.h:50
rb_ractor_stderr_set
void rb_ractor_stderr_set(VALUE)
Definition: ractor.c:2184
rb_ractor_make_shareable
VALUE rb_ractor_make_shareable(VALUE obj)
Definition: ractor.c:2499
rb_ractor_local_storage_value_newkey
rb_ractor_local_key_t rb_ractor_local_storage_value_newkey(void)
Definition: ractor.c:3106
rb_ractor_local_storage_value
VALUE rb_ractor_local_storage_value(rb_ractor_local_key_t key)
Definition: ractor.c:3166
SPECIAL_CONST_P
#define SPECIAL_CONST_P
Definition: special_consts.h:47
rb_ractor_local_key_struct
Definition: ractor.c:3007
rb_ractor_local_storage_type
Definition: ractor.h:15
rb_ractor_local_storage_type::free
void(* free)(void *ptr)
Definition: ractor.h:17
rb_ractor_local_storage_type::mark
void(* mark)(void *ptr)
Definition: ractor.h:16
VALUE
unsigned long VALUE
Definition: value.h:38