summaryrefslogtreecommitdiff
path: root/ractor_core.h
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-11-28 04:39:09 +0900
committerKoichi Sasada <ko1@atdot.net>2020-12-01 09:39:30 +0900
commit67693d8d806e67d6e50b303dd0be6ec06b81c853 (patch)
treeb0947049393400f046ac554b7f3573cd73b80af0 /ractor_core.h
parente79f1941b29738d95b42f8cb5bdb159e7138cf49 (diff)
ractor local storage C-API
To manage ractor-local data for C extension, the following APIs are defined. * rb_ractor_local_storage_value_newkey * rb_ractor_local_storage_value * rb_ractor_local_storage_value_set * rb_ractor_local_storage_ptr_newkey * rb_ractor_local_storage_ptr * rb_ractor_local_storage_ptr_set At first, you need to create a key of storage by rb_ractor_local_(value|ptr)_newkey(). For ptr storage, it accepts the type of storage, how to mark and how to free with ractor's lifetime. rb_ractor_local_storage_value/set are used to access a VALUE and rb_ractor_local_storage_ptr/set are used to access a pointer. random.c uses this API.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3822
Diffstat (limited to 'ractor_core.h')
-rw-r--r--ractor_core.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/ractor_core.h b/ractor_core.h
index 6e9a63dc28..b0295155ac 100644
--- a/ractor_core.h
+++ b/ractor_core.h
@@ -123,14 +123,16 @@ struct rb_ractor_struct {
struct list_node vmlr_node;
+ // ractor local data
+
+ st_table *local_storage;
+
VALUE r_stdin;
VALUE r_stdout;
VALUE r_stderr;
VALUE verbose;
VALUE debug;
- struct rb_random_struct *default_rand; // used in random.c
-
// gc.c rb_objspace_reachable_objects_from
struct gc_mark_func_data_struct {
void *data;
@@ -163,9 +165,15 @@ void rb_ractor_vm_barrier_interrupt_running_thread(rb_ractor_t *r);
void rb_ractor_terminate_interrupt_main_thread(rb_ractor_t *r);
void rb_ractor_terminate_all(void);
bool rb_ractor_main_p_(void);
+void rb_ractor_finish_marking(void);
RUBY_SYMBOL_EXPORT_BEGIN
bool rb_ractor_shareable_p_continue(VALUE obj);
+
+// THIS FUNCTION SHOULD NOT CALL WHILE INCREMENTAL MARKING!!
+// This function is for T_DATA::free_func
+void rb_ractor_local_storage_delkey(rb_ractor_local_key_t key);
+
RUBY_SYMBOL_EXPORT_END
RUBY_EXTERN bool ruby_multi_ractor;