mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
expose some C-APIs for ractor
expose some C-APIs to try to make ractor utilities on external gems. * add * rb_ractor_local_storage_value_lookup() to check availability * expose * rb_ractor_make_shareable() * rb_ractor_make_shareable_copy() * rb_proc_isolate() (not public) * rb_proc_isolate_bang() (not public) * rb_proc_ractor_make_shareable() (not public)
This commit is contained in:
parent
b2beb8586e
commit
1614dd9fd4
3 changed files with 17 additions and 3 deletions
|
@ -32,6 +32,7 @@ void rb_ractor_stderr_set(VALUE);
|
||||||
|
|
||||||
rb_ractor_local_key_t rb_ractor_local_storage_value_newkey(void);
|
rb_ractor_local_key_t rb_ractor_local_storage_value_newkey(void);
|
||||||
VALUE rb_ractor_local_storage_value(rb_ractor_local_key_t key);
|
VALUE rb_ractor_local_storage_value(rb_ractor_local_key_t key);
|
||||||
|
bool rb_ractor_local_storage_value_lookup(rb_ractor_local_key_t key, VALUE *val);
|
||||||
void rb_ractor_local_storage_value_set(rb_ractor_local_key_t key, VALUE val);
|
void rb_ractor_local_storage_value_set(rb_ractor_local_key_t key, VALUE val);
|
||||||
|
|
||||||
RUBY_EXTERN const struct rb_ractor_local_storage_type rb_ractor_local_storage_type_free;
|
RUBY_EXTERN const struct rb_ractor_local_storage_type rb_ractor_local_storage_type_free;
|
||||||
|
@ -41,6 +42,9 @@ rb_ractor_local_key_t rb_ractor_local_storage_ptr_newkey(const struct rb_ractor_
|
||||||
void *rb_ractor_local_storage_ptr(rb_ractor_local_key_t key);
|
void *rb_ractor_local_storage_ptr(rb_ractor_local_key_t key);
|
||||||
void rb_ractor_local_storage_ptr_set(rb_ractor_local_key_t key, void *ptr);
|
void rb_ractor_local_storage_ptr_set(rb_ractor_local_key_t key, void *ptr);
|
||||||
|
|
||||||
|
VALUE rb_ractor_make_shareable(VALUE obj);
|
||||||
|
VALUE rb_ractor_make_shareable_copy(VALUE obj);
|
||||||
|
|
||||||
RUBY_SYMBOL_EXPORT_END
|
RUBY_SYMBOL_EXPORT_END
|
||||||
|
|
||||||
#define RB_OBJ_SHAREABLE_P(obj) FL_TEST_RAW((obj), RUBY_FL_SHAREABLE)
|
#define RB_OBJ_SHAREABLE_P(obj) FL_TEST_RAW((obj), RUBY_FL_SHAREABLE)
|
||||||
|
@ -61,7 +65,4 @@ rb_ractor_shareable_p(VALUE obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rb_ractor_make_shareable(VALUE obj);
|
|
||||||
VALUE rb_ractor_make_shareable_copy(VALUE obj);
|
|
||||||
|
|
||||||
#endif /* RUBY_RACTOR_H */
|
#endif /* RUBY_RACTOR_H */
|
||||||
|
|
11
ractor.c
11
ractor.c
|
@ -3128,6 +3128,17 @@ rb_ractor_local_storage_value(rb_ractor_local_key_t key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
rb_ractor_local_storage_value_lookup(rb_ractor_local_key_t key, VALUE *val)
|
||||||
|
{
|
||||||
|
if (ractor_local_ref(key, (void **)val)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_ractor_local_storage_value_set(rb_ractor_local_key_t key, VALUE val)
|
rb_ractor_local_storage_value_set(rb_ractor_local_key_t key, VALUE val)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1085,9 +1085,11 @@ typedef struct {
|
||||||
unsigned int is_isolated: 1; /* bool */
|
unsigned int is_isolated: 1; /* bool */
|
||||||
} rb_proc_t;
|
} rb_proc_t;
|
||||||
|
|
||||||
|
RUBY_SYMBOL_EXPORT_BEGIN
|
||||||
VALUE rb_proc_isolate(VALUE self);
|
VALUE rb_proc_isolate(VALUE self);
|
||||||
VALUE rb_proc_isolate_bang(VALUE self);
|
VALUE rb_proc_isolate_bang(VALUE self);
|
||||||
VALUE rb_proc_ractor_make_shareable(VALUE self);
|
VALUE rb_proc_ractor_make_shareable(VALUE self);
|
||||||
|
RUBY_SYMBOL_EXPORT_END
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
VALUE flags; /* imemo header */
|
VALUE flags; /* imemo header */
|
||||||
|
|
Loading…
Add table
Reference in a new issue