14#ifdef THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION
18#if defined(__wasm__) && !defined(__EMSCRIPTEN__)
19# include "wasm/machine.h"
22#define TIME_QUANTUM_MSEC (100)
23#define TIME_QUANTUM_USEC (TIME_QUANTUM_MSEC * 1000)
24#define TIME_QUANTUM_NSEC (TIME_QUANTUM_USEC * 1000)
37#define thread_sched_to_dead thread_sched_to_waiting
114static rb_thread_t *ruby_native_thread;
117ruby_thread_from_native(
void)
119 return ruby_native_thread;
123ruby_thread_set_native(rb_thread_t *th)
126 rb_ractor_set_current_ec(th->ractor, th->ec);
128 ruby_native_thread = th;
133Init_native_thread(rb_thread_t *main_th)
136 ruby_thread_set_native(main_th);
140ruby_mn_threads_params(
void)
150native_thread_init_stack(rb_thread_t *th)
152#if defined(__wasm__) && !defined(__EMSCRIPTEN__)
153 th->ec->machine.stack_start = (
VALUE *)rb_wasm_stack_get_base();
159native_thread_create(rb_thread_t *th)
161 th->status = THREAD_KILLED;
162 rb_ractor_living_threads_remove(th->ractor, th);
167#define register_ubf_list(th) (void)(th)
168#define unregister_ubf_list(th) (void)(th)
172ubf_wakeup_all_threads(
void)
178ubf_threads_empty(
void)
189ubf_timer_disarm(
void)
195#define TIMER_THREAD_CREATED_P() (1)
197rb_thread_create_timer_thread(
void)
202rb_thread_wakeup_timer_thread(
int sig)
207native_stop_timer_thread(
void)
213native_reset_timer_thread(
void)
219native_set_thread_name(rb_thread_t *th)
224native_set_another_thread_name(rb_nativethread_id_t thread_id,
VALUE name)
229#define USE_NATIVE_THREAD_NATIVE_THREAD_ID 0
248rb_sigwait_fd_get(
const rb_thread_t *th)
253NORETURN(
void rb_sigwait_fd_put(rb_thread_t *,
int));
255rb_sigwait_fd_put(rb_thread_t *th,
int fd)
257 rb_bug(
"not implemented, should not be called rb_sigwait_fd_put");
260NORETURN(
void rb_sigwait_sleep(
const rb_thread_t *,
int,
const rb_hrtime_t *));
262rb_sigwait_sleep(
const rb_thread_t *th,
int sigwait_fd,
const rb_hrtime_t *rel)
264 rb_bug(
"not implemented, should not be called rb_sigwait_sleep");
268native_sleep(rb_thread_t *th, rb_hrtime_t *rel)
272 (void)clock_nanosleep(CLOCK_REALTIME, 0, rb_hrtime2timespec(&ts, rel), NULL);
278 return rb_fd_select(n, readfds, writefds, exceptfds, timeout);
282th_has_dedicated_nt(
const rb_thread_t *th)
288rb_add_running_thread(rb_thread_t *th){
293rb_del_running_thread(rb_thread_t *th)
299rb_threadptr_sched_free(rb_thread_t *th)
305rb_ractor_sched_barrier_start(rb_vm_t *vm, rb_ractor_t *cr)
311rb_ractor_sched_barrier_join(rb_vm_t *vm, rb_ractor_t *cr)
317rb_threadptr_remove(rb_thread_t *th)
323rb_thread_sched_mark_zombies(rb_vm_t *vm)
void ruby_init_stack(volatile VALUE *addr)
Set stack bottom of Ruby implementation.
void rb_notimplement(void)
int rb_reserved_fd_p(int fd)
Queries if the given FD is reserved or not.
#define rb_fd_select
Waits for multiple file descriptors at once.
The data structure which wraps the fd_set bitmap used by select(2).
rb_nativethread_id_t rb_nativethread_self(void)
Queries the ID of the native thread that is calling this function.
void rb_native_mutex_lock(rb_nativethread_lock_t *lock)
Just another name of rb_nativethread_lock_lock.
void rb_native_cond_initialize(rb_nativethread_cond_t *cond)
Fills the passed condition variable with an initial value.
int rb_native_mutex_trylock(rb_nativethread_lock_t *lock)
Identical to rb_native_mutex_lock(), except it doesn't block in case rb_native_mutex_lock() would.
void rb_native_cond_broadcast(rb_nativethread_cond_t *cond)
Signals a condition variable.
void rb_native_mutex_initialize(rb_nativethread_lock_t *lock)
Just another name of rb_nativethread_lock_initialize.
void rb_native_mutex_unlock(rb_nativethread_lock_t *lock)
Just another name of rb_nativethread_lock_unlock.
void rb_native_mutex_destroy(rb_nativethread_lock_t *lock)
Just another name of rb_nativethread_lock_destroy.
void rb_native_cond_destroy(rb_nativethread_cond_t *cond)
Destroys the passed condition variable.
void rb_native_cond_signal(rb_nativethread_cond_t *cond)
Signals a condition variable.
void rb_native_cond_wait(rb_nativethread_cond_t *cond, rb_nativethread_lock_t *mutex)
Waits for the passed condition variable to be signalled.
void rb_native_cond_timedwait(rb_nativethread_cond_t *cond, rb_nativethread_lock_t *mutex, unsigned long msec)
Identical to rb_native_cond_wait(), except it additionally takes timeout in msec resolution.
uintptr_t VALUE
Type that represents a Ruby object.