diff options
author | Koichi Sasada <ko1@atdot.net> | 2022-04-22 21:19:03 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2022-04-23 03:08:27 +0900 |
commit | 03d21a4fb099da7c52e6591e17704c297871b7db (patch) | |
tree | db2d58907b7c841d8ca15967f063d229bd9e37cc /vm_core.h | |
parent | 69d41480ec1c91691b79f106f5376a2e2cab3a82 (diff) |
introduce struct `rb_native_thread`
`rb_thread_t` contained `native_thread_data_t` to represent
thread implementation dependent data. This patch separates
them and rename it `rb_native_thread` and point it from
`rb_thraed_t`.
Now, 1 Ruby thread (`rb_thread_t`) has 1 native thread (`rb_native_thread`).
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5836
Diffstat (limited to 'vm_core.h')
-rw-r--r-- | vm_core.h | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -68,6 +68,10 @@ # include <setjmp.h> #endif +#if defined(__linux__) || defined(__FreeBSD__) +# define RB_THREAD_T_HAS_NATIVE_ID +#endif + #include "ruby/internal/stdbool.h" #include "ccan/list/list.h" #include "id.h" @@ -969,18 +973,18 @@ struct rb_ext_config { typedef struct rb_ractor_struct rb_ractor_t; -#if defined(__linux__) || defined(__FreeBSD__) -# define RB_THREAD_T_HAS_NATIVE_ID -#endif +struct rb_native_thread; typedef struct rb_thread_struct { struct ccan_list_node lt_node; // managed by a ractor VALUE self; rb_ractor_t *ractor; rb_vm_t *vm; - + struct rb_native_thread *nt; rb_execution_context_t *ec; + struct rb_thread_sched_item sched; + VALUE last_status; /* $? */ /* for cfunc */ @@ -991,15 +995,10 @@ typedef struct rb_thread_struct { VALUE top_wrapper; /* thread control */ - rb_nativethread_id_t thread_id; -#ifdef NON_SCALAR_THREAD_ID - rb_thread_id_string_t thread_id_string; -#endif -#ifdef RB_THREAD_T_HAS_NATIVE_ID - int tid; -#endif + BITFIELD(enum rb_thread_status, status, 2); /* bit flags */ + unsigned int locking_native_thread : 1; unsigned int to_kill : 1; unsigned int abort_on_exception: 1; unsigned int report_on_exception: 1; @@ -1007,7 +1006,6 @@ typedef struct rb_thread_struct { int8_t priority; /* -3 .. 3 (RUBY_THREAD_PRIORITY_{MIN,MAX}) */ uint32_t running_time_us; /* 12500..800000 */ - native_thread_data_t native_thread_data; void *blocking_region_buffer; VALUE thgroup; |