1#ifndef RUBY_THREAD_PTHREAD_H
2#define RUBY_THREAD_PTHREAD_H
13#ifdef HAVE_PTHREAD_NP_H
14#include <pthread_np.h>
17#define RB_NATIVETHREAD_LOCK_INIT PTHREAD_MUTEX_INITIALIZER
18#define RB_NATIVETHREAD_COND_INIT PTHREAD_COND_INITIALIZER
23 struct ccan_list_node ubf;
27 struct ccan_list_node readyq;
31 struct ccan_list_node timeslice_threads;
35 struct ccan_list_node running_threads;
38 struct ccan_list_node zombie_threads;
43 enum thread_sched_waiting_flag {
44 thread_sched_waiting_none = 0x00,
45 thread_sched_waiting_timeout = 0x01,
46 thread_sched_waiting_io_read = 0x02,
47 thread_sched_waiting_io_write = 0x08,
48 thread_sched_waiting_io_force = 0x40,
53#ifdef MY_RUBY_BUILD_MAY_TIME_TRAVEL
63 struct ccan_list_node node;
69 struct coroutine_context *context;
74 struct rb_vm_struct *vm;
76 rb_nativethread_id_t thread_id;
78#ifdef RB_THREAD_T_HAS_NATIVE_ID
82 struct rb_thread_struct *running_thread;
85#if defined(__GLIBC__) || defined(__FreeBSD__)
95 rb_nativethread_cond_t intr;
96 rb_nativethread_cond_t readyq;
103 struct coroutine_context *nt_context;
106 size_t machine_stack_maxsize;
116 rb_nativethread_lock_t lock_;
118 struct rb_thread_struct *lock_owner;
120 struct rb_thread_struct *running;
122 bool is_running_timeslice;
123 bool enable_mn_threads;
125 struct ccan_list_head readyq;
128 struct ccan_list_node grq_node;
131#ifdef RB_THREAD_LOCAL_SPECIFIER
143 #define RUBY_NT_SERIAL 1
146typedef pthread_key_t native_tls_key_t;
149native_tls_get(native_tls_key_t key)
152 return pthread_getspecific(key);
156native_tls_set(native_tls_key_t key,
void *ptr)
158 if (UNLIKELY(pthread_setspecific(key, ptr) != 0)) {
159 rb_bug(
"pthread_setspecific error");
std::atomic< unsigned > rb_atomic_t
Type that is eligible for atomic operations.
#define RUBY_EXTERN
Declaration of externally visible global variables.