summaryrefslogtreecommitdiff
path: root/thread_pthread.h
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2022-04-22 21:19:03 +0900
committerKoichi Sasada <ko1@atdot.net>2022-04-23 03:08:27 +0900
commit03d21a4fb099da7c52e6591e17704c297871b7db (patch)
treedb2d58907b7c841d8ca15967f063d229bd9e37cc /thread_pthread.h
parent69d41480ec1c91691b79f106f5376a2e2cab3a82 (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 'thread_pthread.h')
-rw-r--r--thread_pthread.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/thread_pthread.h b/thread_pthread.h
index f65916fea9..cc1675b77c 100644
--- a/thread_pthread.h
+++ b/thread_pthread.h
@@ -17,11 +17,30 @@
#define RB_NATIVETHREAD_LOCK_INIT PTHREAD_MUTEX_INITIALIZER
#define RB_NATIVETHREAD_COND_INIT PTHREAD_COND_INITIALIZER
-typedef struct native_thread_data_struct {
+// per-Thead scheduler helper data
+struct rb_thread_sched_item {
union {
struct ccan_list_node ubf;
struct ccan_list_node readyq; // protected by sched->lock
} node;
+};
+
+struct rb_native_thread {
+ int id;
+
+ 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
+
+ struct rb_thread_struct *running_thread;
+
+ // to control native thread
#if defined(__GLIBC__) || defined(__FreeBSD__)
union
#else
@@ -31,11 +50,11 @@ typedef struct native_thread_data_struct {
*/
struct
#endif
- {
+ {
rb_nativethread_cond_t intr; /* th->interrupt_lock */
rb_nativethread_cond_t readyq; /* use sched->lock */
} cond;
-} native_thread_data_t;
+};
#undef except
#undef try