summaryrefslogtreecommitdiff
path: root/ractor_core.h
diff options
context:
space:
mode:
Diffstat (limited to 'ractor_core.h')
-rw-r--r--ractor_core.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/ractor_core.h b/ractor_core.h
index 0656ce00a0..c692ebbbbf 100644
--- a/ractor_core.h
+++ b/ractor_core.h
@@ -9,6 +9,9 @@
#define RACTOR_CHECK_MODE (VM_CHECK_MODE || RUBY_DEBUG) && (SIZEOF_UINT64_T == SIZEOF_VALUE)
#endif
+// experimental flag because it is not sure it is the common pattern
+#define RUBY_TYPED_FROZEN_SHAREABLE_NO_REC RUBY_FL_FINALIZE
+
struct rb_ractor_sync {
// ractor lock
rb_nativethread_lock_t lock;
@@ -88,6 +91,8 @@ struct rb_ractor_struct {
// ractor local data
+ rb_serial_t next_ec_serial;
+
st_table *local_storage;
struct rb_id_table *idkey_local_storage;
VALUE local_storage_store_lock;
@@ -98,9 +103,24 @@ struct rb_ractor_struct {
VALUE verbose;
VALUE debug;
+ bool malloc_gc_disabled;
+ bool main_ractor;
void *newobj_cache;
}; // rb_ractor_t is defined in vm_core.h
+enum ractor_wakeup_status {
+ wakeup_none,
+ wakeup_by_send,
+ wakeup_by_interrupt,
+ // wakeup_by_close,
+};
+
+struct ractor_waiter {
+ enum ractor_wakeup_status wakeup_status;
+ rb_thread_t *th;
+ struct ccan_list_node node;
+ rb_atomic_t event_serial;
+};
static inline VALUE
rb_ractor_self(const rb_ractor_t *r)
@@ -138,6 +158,7 @@ VALUE rb_ractor_require(VALUE feature, bool silent);
VALUE rb_ractor_autoload_load(VALUE space, ID id);
VALUE rb_ractor_ensure_shareable(VALUE obj, VALUE name);
+st_table *rb_ractor_targeted_hooks(rb_ractor_t *cr);
RUBY_SYMBOL_EXPORT_BEGIN
void rb_ractor_finish_marking(void);
@@ -244,6 +265,25 @@ rb_ractor_id(const rb_ractor_t *r)
return r->pub.id;
}
+static inline void
+rb_ractor_targeted_hooks_incr(rb_ractor_t *cr)
+{
+ cr->pub.targeted_hooks_cnt++;
+}
+
+static inline void
+rb_ractor_targeted_hooks_decr(rb_ractor_t *cr)
+{
+ RUBY_ASSERT(cr->pub.targeted_hooks_cnt > 0);
+ cr->pub.targeted_hooks_cnt--;
+}
+
+static inline unsigned int
+rb_ractor_targeted_hooks_cnt(rb_ractor_t *cr)
+{
+ return cr->pub.targeted_hooks_cnt;
+}
+
#if RACTOR_CHECK_MODE > 0
# define RACTOR_BELONGING_ID(obj) (*(uint32_t *)(((uintptr_t)(obj)) + rb_gc_obj_slot_size(obj)))