Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Enumerations | Functions
thread.c File Reference
`#include "ruby/config.h"`
`#include "ruby/io.h"`
`#include "eval_intern.h"`
`#include "timev.h"`
`#include "ruby/thread.h"`
`#include "ruby/thread_native.h"`
`#include "ruby/debug.h"`
`#include "gc.h"`
`#include "internal.h"`
`#include "iseq.h"`
`#include "vm_core.h"`
`#include "mjit.h"`
`#include "hrtime.h"`
`#include "thread_sync.c"`

Go to the source code of this file.

## Data Structures
struct | waiting_fd
struct | rb_blocking_region_buffer
struct | join_arg
struct | select_set
struct | select_args
struct | thgroup
struct | exec_recursive_params

## Macros
#define | __USE_FORTIFY_LEVEL 0
#define | USE_NATIVE_THREAD_PRIORITY 0
#define | RUBY_THREAD_PRIORITY_MAX 3
#define | RUBY_THREAD_PRIORITY_MIN -3
#define | THREAD_DEBUG 0
#define | THREAD_LOCAL_STORAGE_INITIALISED FL_USER13
#define | THREAD_LOCAL_STORAGE_INITIALISED_P(th) RB_FL_TEST_RAW((th), THREAD_LOCAL_STORAGE_INITIALISED)
#define | eKillSignal INT2FIX(0)
#define | eTerminateSignal INT2FIX(1)
#define | THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION
#define | RB_GC_SAVE_MACHINE_CONTEXT(th)
#define | GVL_UNLOCK_BEGIN(th)
#define | GVL_UNLOCK_END(th)
#define | only_if_constant(expr, notconst) notconst
#define | BLOCKING_REGION(th, exec, ubf, ubfarg, fail_if_interrupted)
#define | RUBY_VM_CHECK_INTS_BLOCKING(ec) vm_check_ints_blocking(ec)
#define | thread_debug if(0)printf
#define | fill_thread_id_string(thid, buf) ((void *)(uintptr_t)(thid))
#define | fill_thread_id_str(th) (void)0
#define | thread_id_str(th) ((void *)(uintptr_t)(th)->thread_id)
#define | PRI_THREAD_ID "p"
#define | BUSY_WAIT_SIGNALS (0)
#define | USE_EVENTFD (0)
#define | threadptr_initialized(th) ((th)->invoke_type != thread_invoke_type_none)
#define | TIMESPEC_SEC_MAX TIMET_MAX
#define | TIMESPEC_SEC_MIN TIMET_MIN
#define | PRIu64 PRI_64_PREFIX "u"
#define | rb_fd_no_init(fds) (void)(fds)
#define | restore_fdset(dst, src) ((dst) ? rb_fd_dup(dst, src) : (void)0)
#define | do_select_update()
#define | fd_init_copy(f)
#define | GetThreadShieldPtr(obj) ((VALUE)rb_check_typeddata((obj), &thread_shield_data_type))
#define | THREAD_SHIELD_WAITING_MASK (((FL_USER19-1)&~(FL_USER0-1))|FL_USER19)
#define | THREAD_SHIELD_WAITING_SHIFT (FL_USHIFT)
#define | THREAD_SHIELD_WAITING_MAX (THREAD_SHIELD_WAITING_MASK>>THREAD_SHIELD_WAITING_SHIFT)
#define | OBJ_ID_EQL(obj_id, other) ((obj_id) == (other))
#define | rb_intern(str) rb_intern_const(str)

## Enumerations
enum | SLEEP_FLAGS { SLEEP_DEADLOCKABLE = 0x1, SLEEP_SPURIOUS_CHECK = 0x2 }
enum | handle_interrupt_timing { INTERRUPT_NONE, INTERRUPT_IMMEDIATE, INTERRUPT_ON_BLOCKING, INTERRUPT_NEVER }

## Functions
| NORETURN (static void async_bug_fd(const char *mesg, int errno_arg, int fd))
void | rb_sigwait_fd_migrate (rb_vm_t *)
| NOINLINE (static int thread_start_func_2(rb_thread_t *th, VALUE *stack_start))
void | ruby_sigchld_handler (rb_vm_t *)
void | rb_vm_gvl_destroy (rb_vm_t *vm)
void | rb_nativethread_lock_initialize (rb_nativethread_lock_t *lock)
void | rb_nativethread_lock_destroy (rb_nativethread_lock_t *lock)
void | rb_nativethread_lock_lock (rb_nativethread_lock_t *lock)
void | rb_nativethread_lock_unlock (rb_nativethread_lock_t *lock)
void | rb_threadptr_interrupt (rb_thread_t *th)
void | rb_threadptr_unlock_all_locking_mutexes (rb_thread_t *th)
void | rb_thread_terminate_all (void)
void | rb_threadptr_root_fiber_terminate (rb_thread_t *th)
void | ruby_thread_init_stack (rb_thread_t *th)
const VALUE * | rb_vm_proc_local_ep (VALUE proc)
void | rb_ec_clear_current_thread_trace_func (const rb_execution_context_t *ec)
VALUE | rb_thread_create (VALUE(*fn)(void *), void *arg)
| NOINLINE (rb_hrtime_t rb_hrtime_now(void))
rb_hrtime_t | rb_hrtime_now (void)
void | rb_thread_sleep_forever (void)
void | rb_thread_sleep_deadly (void)
void | rb_thread_sleep_interruptible (void)
void | rb_thread_wait_for (struct timeval time)
void | rb_thread_check_ints (void)
int | rb_thread_check_trap_pending (void)
int | rb_thread_interrupted (VALUE thval)
void | rb_thread_sleep (int sec)
void | rb_thread_schedule (void)
void * | rb_nogvl (void *(*func)(void *), void *data1, rb_unblock_function_t *ubf, void *data2, int flags)
void * | rb_thread_call_without_gvl2 (void *(*func)(void *), void *data1, rb_unblock_function_t *ubf, void *data2)
void * | rb_thread_call_without_gvl (void *(*func)(void *data), void *data1, rb_unblock_function_t *ubf, void *data2)
VALUE | rb_thread_io_blocking_region (rb_blocking_function_t *func, void *data1, int fd)
void * | rb_thread_call_with_gvl (void *(*func)(void *), void *data1)
int | ruby_thread_has_gvl_p (void)
void | rb_threadptr_pending_interrupt_clear (rb_thread_t *th)
void | rb_threadptr_pending_interrupt_enque (rb_thread_t *th, VALUE v)
| NORETURN (static void rb_threadptr_to_kill(rb_thread_t *th))
MJIT_FUNC_EXPORTED int | rb_threadptr_execute_interrupts (rb_thread_t *th, int blocking_timing)
void | rb_thread_execute_interrupts (VALUE thval)
void | rb_threadptr_signal_raise (rb_thread_t *th, int sig)
void | rb_threadptr_signal_exit (rb_thread_t *th)
int | rb_ec_set_raised (rb_execution_context_t *ec)
int | rb_ec_reset_raised (rb_execution_context_t *ec)
int | rb_notify_fd_close (int fd, struct list_head *busy)
void | rb_thread_fd_close (int fd)
VALUE | rb_thread_kill (VALUE thread)
int | rb_thread_to_be_killed (VALUE thread)
VALUE | rb_thread_wakeup (VALUE thread)
VALUE | rb_thread_wakeup_alive (VALUE thread)
VALUE | rb_thread_run (VALUE thread)
VALUE | rb_thread_stop (void)
VALUE | rb_thread_list (void)
VALUE | rb_thread_current (void)
VALUE | rb_thread_main (void)
VALUE | rb_thread_group (VALUE thread)
VALUE | rb_thread_local_aref (VALUE thread, ID id)
VALUE | rb_thread_local_aset (VALUE thread, ID id, VALUE val)
int | rb_thread_alone (void)
void | rb_thread_wait_fd (int fd)
int | rb_thread_fd_writable (int fd)
int | rb_thread_fd_select (int max, rb_fdset_t *read, rb_fdset_t *write, rb_fdset_t *except, struct timeval *timeout)
int | rb_wait_for_single_fd (int fd, int events, struct timeval *tv)
void | rb_gc_set_stack_end (VALUE **stack_end_p)
void | rb_threadptr_check_signal (rb_thread_t *mth)
void | rb_thread_stop_timer_thread (void)
void | rb_thread_reset_timer_thread (void)
void | rb_thread_start_timer_thread (void)
void | rb_clear_coverages (void)
void | rb_thread_atfork (void)
void | rb_thread_atfork_before_exec (void)
| STATIC_ASSERT (THREAD_SHIELD_WAITING_MAX, THREAD_SHIELD_WAITING_MAX<=UINT_MAX)
VALUE | rb_thread_shield_new (void)
VALUE | rb_thread_shield_wait (VALUE self)
VALUE | rb_thread_shield_release (VALUE self)
VALUE | rb_thread_shield_destroy (VALUE self)
ID | rb_frame_last_func (void)
| Returns the ID of the last method in the call stack. More...
VALUE | rb_exec_recursive (VALUE(*func)(VALUE, VALUE, int), VALUE obj, VALUE arg)
VALUE | rb_exec_recursive_paired (VALUE(*func)(VALUE, VALUE, int), VALUE obj, VALUE paired_obj, VALUE arg)
VALUE | rb_exec_recursive_outer (VALUE(*func)(VALUE, VALUE, int), VALUE obj, VALUE arg)
VALUE | rb_exec_recursive_paired_outer (VALUE(*func)(VALUE, VALUE, int), VALUE obj, VALUE paired_obj, VALUE arg)
void | Init_Thread (void)
int | ruby_native_thread_p (void)
const rb_method_entry_t * | rb_resolve_me_location (const rb_method_entry_t *me, VALUE resolved_location[5])
VALUE | rb_get_coverages (void)
int | rb_get_coverage_mode (void)
void | rb_set_coverages (VALUE coverages, int mode, VALUE me2counter)
void | rb_reset_coverages (void)
VALUE | rb_default_coverage (int n)
VALUE | rb_uninterruptible (VALUE(*b_proc)(VALUE), VALUE data)

## Macro Definition Documentation

## ◆ __USE_FORTIFY_LEVEL

#define __USE_FORTIFY_LEVEL 0

Definition at line 62 of file thread.c.

## ◆ BLOCKING_REGION

#define BLOCKING_REGION | ( |  | th,
|  |  | exec,
|  |  | ubf,
|  |  | ubfarg,
|  |  | fail_if_interrupted
| ) |  |

Value:
do { \
struct rb_blocking_region_buffer __region; \
if (blocking_region_begin(th, &__region, (ubf), (ubfarg), fail_if_interrupted) || \
/* always return true unless fail_if_interrupted */ \
!only_if_constant(fail_if_interrupted, TRUE)) { \
exec; \
blocking_region_end(th, &__region); \
}; \
} while(0)

Definition at line 188 of file thread.c.

## ◆ BUSY_WAIT_SIGNALS

#define BUSY_WAIT_SIGNALS (0)

Definition at line 379 of file thread.c.

## ◆ do_select_update

#define do_select_update | ( |  | ) |

Value:
(restore_fdset(set->rset, &set->orig_rset), \
restore_fdset(set->wset, &set->orig_wset), \
restore_fdset(set->eset, &set->orig_eset), \
TRUE)

## ◆ eKillSignal

#define eKillSignal INT2FIX(0)

Definition at line 132 of file thread.c.

## ◆ eTerminateSignal

#define eTerminateSignal INT2FIX(1)

Definition at line 133 of file thread.c.

## ◆ fd_init_copy

#define fd_init_copy | ( |  | f | ) |

Value:
do { \
if (set.f) { \
rb_fd_resize(set.max - 1, set.f); \
if (&set.orig_##f != set.f) { /* sigwait_fd */ \
rb_fd_init_copy(&set.orig_##f, set.f); \
} \
} \
else { \
rb_fd_no_init(&set.orig_##f); \
} \
} while (0)

## ◆ fill_thread_id_str

#define fill_thread_id_str | ( |  | th | ) | (void)0

Definition at line 335 of file thread.c.

## ◆ fill_thread_id_string

#define fill_thread_id_string | ( |  | thid,
|  |  | buf
| ) |  | ((void *)(uintptr_t)(thid))

Definition at line 334 of file thread.c.

## ◆ GetThreadShieldPtr

#define GetThreadShieldPtr | ( |  | obj | ) | ((VALUE)rb_check_typeddata((obj), &thread_shield_data_type))

Definition at line 4757 of file thread.c.

## ◆ GVL_UNLOCK_BEGIN

#define GVL_UNLOCK_BEGIN | ( |  | th | ) |

Value:
do { \
RB_GC_SAVE_MACHINE_CONTEXT(th); \
gvl_release(th->vm);

Definition at line 170 of file thread.c.

## ◆ GVL_UNLOCK_END

#define GVL_UNLOCK_END | ( |  | th | ) |

Value:
gvl_acquire(th->vm, th); \
rb_thread_set_current(th); \
} while(0)

Definition at line 174 of file thread.c.

## ◆ OBJ_ID_EQL

#define OBJ_ID_EQL | ( |  | obj_id,
|  |  | other
| ) |  | ((obj_id) == (other))

## ◆ only_if_constant

#define only_if_constant | ( |  | expr,
|  |  | notconst
| ) |  | notconst

Definition at line 186 of file thread.c.

## ◆ PRI_THREAD_ID

#define PRI_THREAD_ID "p"

Definition at line 337 of file thread.c.

## ◆ PRIu64

#define PRIu64 PRI_64_PREFIX "u"

Definition at line 1272 of file thread.c.

## ◆ rb_fd_no_init

#define rb_fd_no_init | ( |  | fds | ) | (void)(fds)

Definition at line 3893 of file thread.c.

## ◆ RB_GC_SAVE_MACHINE_CONTEXT

#define RB_GC_SAVE_MACHINE_CONTEXT | ( |  | th | ) |

Value:
do { \
FLUSH_REGISTER_WINDOWS; \
setjmp((th)->ec->machine.regs); \
SET_MACHINE_STACK_END(&(th)->ec->machine.stack_end); \
} while (0)

Definition at line 163 of file thread.c.

## ◆ rb_intern

#define rb_intern | ( |  | str | ) | rb_intern_const(str)

## ◆ restore_fdset

#define restore_fdset | ( |  | dst,
|  |  | src
| ) |  | ((dst) ? rb_fd_dup(dst, src) : (void)0)

## ◆ RUBY_THREAD_PRIORITY_MAX

#define RUBY_THREAD_PRIORITY_MAX 3

Definition at line 87 of file thread.c.

## ◆ RUBY_THREAD_PRIORITY_MIN

#define RUBY_THREAD_PRIORITY_MIN -3

Definition at line 88 of file thread.c.

## ◆ RUBY_VM_CHECK_INTS_BLOCKING

#define RUBY_VM_CHECK_INTS_BLOCKING | ( |  | ec | ) | vm_check_ints_blocking(ec)

Definition at line 202 of file thread.c.

## ◆ THREAD_DEBUG

#define THREAD_DEBUG 0

Definition at line 92 of file thread.c.

## ◆ thread_debug

#define thread_debug if(0)printf

Definition at line 330 of file thread.c.

## ◆ thread_id_str

#define thread_id_str | ( |  | th | ) | ((void *)(uintptr_t)(th)->thread_id)

Definition at line 336 of file thread.c.

## ◆ THREAD_LOCAL_STORAGE_INITIALISED

#define THREAD_LOCAL_STORAGE_INITIALISED FL_USER13

Definition at line 106 of file thread.c.

## ◆ THREAD_LOCAL_STORAGE_INITIALISED_P

#define THREAD_LOCAL_STORAGE_INITIALISED_P | ( |  | th | ) | RB_FL_TEST_RAW((th), THREAD_LOCAL_STORAGE_INITIALISED)

Definition at line 107 of file thread.c.

## ◆ THREAD_SHIELD_WAITING_MASK

#define THREAD_SHIELD_WAITING_MASK (((FL_USER19-1)&~(FL_USER0-1))|FL_USER19)

Definition at line 4758 of file thread.c.

## ◆ THREAD_SHIELD_WAITING_MAX

#define THREAD_SHIELD_WAITING_MAX (THREAD_SHIELD_WAITING_MASK>>THREAD_SHIELD_WAITING_SHIFT)

Definition at line 4760 of file thread.c.

## ◆ THREAD_SHIELD_WAITING_SHIFT

#define THREAD_SHIELD_WAITING_SHIFT (FL_USHIFT)

Definition at line 4759 of file thread.c.

## ◆ THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION

#define THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION

Definition at line 150 of file thread.c.

## ◆ threadptr_initialized

#define threadptr_initialized | ( |  | th | ) | ((th)->invoke_type != thread_invoke_type_none)

Definition at line 873 of file thread.c.

## ◆ TIMESPEC_SEC_MAX

#define TIMESPEC_SEC_MAX TIMET_MAX

Definition at line 1192 of file thread.c.

## ◆ TIMESPEC_SEC_MIN

#define TIMESPEC_SEC_MIN TIMET_MIN

Definition at line 1193 of file thread.c.

## ◆ USE_EVENTFD

#define USE_EVENTFD (0)

Definition at line 383 of file thread.c.

## ◆ USE_NATIVE_THREAD_PRIORITY

#define USE_NATIVE_THREAD_PRIORITY 0

Definition at line 86 of file thread.c.

## Enumeration Type Documentation

## ◆ handle_interrupt_timing

enum handle_interrupt_timing

Enumerator
INTERRUPT_NONE |
INTERRUPT_IMMEDIATE |
INTERRUPT_ON_BLOCKING |
INTERRUPT_NEVER |

Definition at line 1771 of file thread.c.

## ◆ SLEEP_FLAGS

enum SLEEP_FLAGS

Enumerator
SLEEP_DEADLOCKABLE |
SLEEP_SPURIOUS_CHECK |

Definition at line 101 of file thread.c.

## Function Documentation

## ◆ Init_Thread()

void Init_Thread | ( | void |  | ) |

Definition at line 5162 of file thread.c.

References GET_THREAD.

## ◆ NOINLINE() [1/2]

NOINLINE | ( | rb_hrtime_t | rb_hrtime_nowvoid | ) |

## ◆ NOINLINE() [2/2]

NOINLINE | ( | static int | thread_start_func_2rb_thread_t *th, VALUE *stack_start | ) |

## ◆ NORETURN() [1/2]

NORETURN | ( | static void | async_bug_fdconst char *mesg, int errno_arg, int fd | ) |

## ◆ NORETURN() [2/2]

NORETURN | ( | static void | rb_threadptr_to_killrb_thread_t *th | ) |

## ◆ rb_clear_coverages()

void rb_clear_coverages | ( | void |  | ) |

Definition at line 4468 of file thread.c.

References rb_get_coverages(), rb_hash_foreach(), and RTEST.

Referenced by rb_reset_coverages().

## ◆ rb_default_coverage()

VALUE rb_default_coverage | ( | int | n | ) |

Definition at line 5519 of file thread.c.

References COVERAGE_INDEX_BRANCHES, COVERAGE_INDEX_LINES, COVERAGE_TARGET_BRANCHES, COVERAGE_TARGET_LINES, GET_VM, n, Qfalse, RARRAY_ASET, rb_ary_tmp_new(), and rb_ary_tmp_new_fill().

Referenced by rb_iseq_new_top().

## ◆ rb_ec_clear_current_thread_trace_func()

void rb_ec_clear_current_thread_trace_func | ( | const rb_execution_context_t * | ec | ) |

Definition at line 274 of file vm_trace.c.

## ◆ rb_ec_reset_raised()

int rb_ec_reset_raised | ( | rb_execution_context_t * | ec | ) |

Definition at line 2354 of file thread.c.

References RAISED_EXCEPTION, and rb_execution_context_struct::raised_flag.

## ◆ rb_ec_set_raised()

int rb_ec_set_raised | ( | rb_execution_context_t * | ec | ) |

Definition at line 2344 of file thread.c.

References RAISED_EXCEPTION, and rb_execution_context_struct::raised_flag.

## ◆ rb_exec_recursive()

VALUE rb_exec_recursive | ( | VALUE(*)(VALUE, VALUE, int) | func,
|  | VALUE | obj,
|  | VALUE | arg
| ) |  |

Definition at line 5075 of file thread.c.

Referenced by rb_invcmp(), and rb_io_puts().

## ◆ rb_exec_recursive_outer()

VALUE rb_exec_recursive_outer | ( | VALUE(*)(VALUE, VALUE, int) | func,
|  | VALUE | obj,
|  | VALUE | arg
| ) |  |

Definition at line 5098 of file thread.c.

Referenced by rb_hash().

## ◆ rb_exec_recursive_paired()

VALUE rb_exec_recursive_paired | ( | VALUE(*)(VALUE, VALUE, int) | func,
|  | VALUE | obj,
|  | VALUE | paired_obj,
|  | VALUE | arg
| ) |  |

Definition at line 5086 of file thread.c.

Referenced by rb_ary_cmp().

## ◆ rb_exec_recursive_paired_outer()

VALUE rb_exec_recursive_paired_outer | ( | VALUE(*)(VALUE, VALUE, int) | func,
|  | VALUE | obj,
|  | VALUE | paired_obj,
|  | VALUE | arg
| ) |  |

Definition at line 5110 of file thread.c.

## ◆ rb_gc_set_stack_end()

void rb_gc_set_stack_end | ( | VALUE ** | stack_end_p | ) |

Definition at line 4306 of file thread.c.

## ◆ rb_get_coverage_mode()

int rb_get_coverage_mode | ( | void |  | ) |

Definition at line 5483 of file thread.c.

References GET_VM.

Referenced by rb_iseq_new_top().

## ◆ rb_get_coverages()

VALUE rb_get_coverages | ( | void |  | ) |

Definition at line 5477 of file thread.c.

References GET_VM.

Referenced by rb_clear_coverages(), and rb_iseq_new_top().

## ◆ rb_hrtime_now()

rb_hrtime_t rb_hrtime_now | ( | void |  | ) |

Definition at line 1229 of file thread.c.

## ◆ rb_nativethread_lock_destroy()

void rb_nativethread_lock_destroy | ( | rb_nativethread_lock_t * | lock | ) |

Definition at line 439 of file thread.c.

References rb_native_mutex_destroy().

## ◆ rb_nativethread_lock_initialize()

void rb_nativethread_lock_initialize | ( | rb_nativethread_lock_t * | lock | ) |

Definition at line 433 of file thread.c.

References rb_native_mutex_initialize().

## ◆ rb_nativethread_lock_lock()

void rb_nativethread_lock_lock | ( | rb_nativethread_lock_t * | lock | ) |

Definition at line 445 of file thread.c.

References rb_native_mutex_lock().

Referenced by rb_grantpt(), and rb_workqueue_register().

## ◆ rb_nativethread_lock_unlock()

void rb_nativethread_lock_unlock | ( | rb_nativethread_lock_t * | lock | ) |

Definition at line 451 of file thread.c.

References rb_native_mutex_unlock().

Referenced by rb_grantpt(), and rb_workqueue_register().

## ◆ rb_nogvl()

void* rb_nogvl | ( | void *(*)(void *) | func,
|  | void * | data1,
|  | rb_unblock_function_t * | ubf,
|  | void * | data2,
|  | int | flags
| ) |  |

Definition at line 1452 of file thread.c.

References GET_EC.

Referenced by rb_thread_call_without_gvl(), and rb_thread_call_without_gvl2().

## ◆ rb_notify_fd_close()

int rb_notify_fd_close | ( | int | fd,
|  | struct list_head * | busy
| ) |  |

Definition at line 2364 of file thread.c.

References err, waiting_fd::fd, GET_THREAD, list_add, list_del, list_empty, list_for_each_safe, rb_threadptr_interrupt(), rb_threadptr_pending_interrupt_enque(), ruby_error_stream_closed, rb_vm_struct::special_exceptions, waiting_fd::th, rb_thread_struct::vm, rb_vm_struct::waiting_fds, and waiting_fd::wfd_node.

## ◆ rb_reset_coverages()

void rb_reset_coverages | ( | void |  | ) |

Definition at line 5504 of file thread.c.

References GET_VM, Qfalse, rb_clear_coverages(), rb_iseq_remove_coverage_all(), and rb_remove_event_hook().

## ◆ rb_resolve_me_location()

const rb_method_entry_t* rb_resolve_me_location | ( | const rb_method_entry_t * | me,
|  | VALUE | resolved_location[5]
| ) |  |

Definition at line 5400 of file thread.c.

References rb_code_location_struct::beg_pos, rb_method_definition_struct::bmethod, rb_method_definition_struct::body, rb_iseq_struct::body, rb_iseq_location_struct::code_location, rb_code_position_struct::column, rb_callable_method_entry_struct::def, rb_code_location_struct::end_pos, INT2FIX, rb_method_definition_struct::iseq, iseq, rb_method_iseq_struct::iseqptr, rb_code_position_struct::lineno, rb_iseq_constant_body::location, me, path, rb_method_bmethod_struct::proc, rb_iseq_path(), rb_proc_get_iseq(), rb_method_definition_struct::type, VM_METHOD_TYPE_BMETHOD, and VM_METHOD_TYPE_ISEQ.

## ◆ rb_set_coverages()

void rb_set_coverages | ( | VALUE | coverages,
|  | int | mode,
|  | VALUE | me2counter
| ) |  |

Definition at line 5489 of file thread.c.

## ◆ rb_sigwait_fd_migrate()

void rb_sigwait_fd_migrate | ( | rb_vm_t * |  | ) |

Definition at line 998 of file process.c.

References rb_native_mutex_lock(), and rb_vm_struct::waitpid_lock.

## ◆ rb_thread_alone()

int rb_thread_alone | ( | void |  | ) |

Definition at line 3492 of file thread.c.

Referenced by rb_thread_stop().

## ◆ rb_thread_atfork()

void rb_thread_atfork | ( | void |  | ) |

Definition at line 4548 of file thread.c.

## ◆ rb_thread_atfork_before_exec()

void rb_thread_atfork_before_exec | ( | void |  | ) |

Definition at line 4553 of file thread.c.

## ◆ rb_thread_call_with_gvl()

void* rb_thread_call_with_gvl | ( | void *(*)(void *) | func,
|  | void * | data1
| ) |  |

Definition at line 1662 of file thread.c.

References rb_thread_struct::blocking_region_buffer, exit(), EXIT_FAILURE, fprintf(), if(), rb_bug(), stderr, waiting_fd::th, and rb_thread_struct::unblock.

Referenced by ossl_generate_cb_2().

## ◆ rb_thread_call_without_gvl()

void* rb_thread_call_without_gvl | ( | void *(*)(void *data) | func,
|  | void * | data1,
|  | rb_unblock_function_t * | ubf,
|  | void * | data2
| ) |  |

Definition at line 1588 of file thread.c.

References rb_nogvl().

## ◆ rb_thread_call_without_gvl2()

void* rb_thread_call_without_gvl2 | ( | void *(*)(void *) | func,
|  | void * | data1,
|  | rb_unblock_function_t * | ubf,
|  | void * | data2
| ) |  |

Definition at line 1581 of file thread.c.

References rb_nogvl(), and RB_NOGVL_INTR_FAIL.

## ◆ rb_thread_check_ints()

void rb_thread_check_ints | ( | void |  | ) |

Definition at line 1362 of file thread.c.

References GET_EC, and RUBY_VM_CHECK_INTS_BLOCKING.

## ◆ rb_thread_check_trap_pending()

int rb_thread_check_trap_pending | ( | void |  | ) |

Definition at line 1372 of file thread.c.

References rb_signal_buff_size().

## ◆ rb_thread_create()

VALUE rb_thread_create | ( | VALUE(*)(void *) | fn,
|  | void * | arg
| ) |  |

Definition at line 966 of file thread.c.

## ◆ rb_thread_current()

VALUE rb_thread_current | ( | void |  | ) |

Definition at line 2676 of file thread.c.

References GET_THREAD.

Referenced by VpGetPrecLimit(), and VpGetRoundMode().

## ◆ rb_thread_execute_interrupts()

void rb_thread_execute_interrupts | ( | VALUE | thval | ) |

Definition at line 2284 of file thread.c.

References rb_threadptr_execute_interrupts().

## ◆ rb_thread_fd_close()

void rb_thread_fd_close | ( | int | fd | ) |

Definition at line 2386 of file thread.c.

## ◆ rb_thread_fd_select()

int rb_thread_fd_select | ( | int | max,
|  | rb_fdset_t * | read,
|  | rb_fdset_t * | write,
|  | rb_fdset_t * | except,
|  | struct timeval * | timeout
| ) |  |

Definition at line 4067 of file thread.c.

## ◆ rb_thread_fd_writable()

int rb_thread_fd_writable | ( | int | fd | ) |

Definition at line 4048 of file thread.c.

## ◆ rb_thread_group()

VALUE rb_thread_group | ( | VALUE | thread | ) |

Definition at line 2966 of file thread.c.

## ◆ rb_thread_interrupted()

int rb_thread_interrupted | ( | VALUE | thval | ) |

Definition at line 1379 of file thread.c.

References RUBY_VM_INTERRUPTED.

## ◆ rb_thread_io_blocking_region()

VALUE rb_thread_io_blocking_region | ( | rb_blocking_function_t * | func,
|  | void * | data1,
|  | int | fd
| ) |  |

Definition at line 1595 of file thread.c.

References waiting_fd::fd, GET_EC, Qundef, and waiting_fd::th.

## ◆ rb_thread_kill()

VALUE rb_thread_kill | ( | VALUE | thread | ) |

Definition at line 2446 of file thread.c.

## ◆ rb_thread_list()

VALUE rb_thread_list | ( | void |  | ) |

Definition at line 2630 of file thread.c.

References GET_THREAD, list_for_each, rb_vm_struct::living_threads, rb_ary_new(), rb_ary_push(), rb_thread_struct::self, rb_thread_struct::status, THREAD_RUNNABLE, THREAD_STOPPED, and THREAD_STOPPED_FOREVER.

## ◆ rb_thread_local_aref()

VALUE rb_thread_local_aref | ( | VALUE | thread,
|  | ID | id
| ) |  |

Definition at line 3216 of file thread.c.

Referenced by VpGetPrecLimit(), and VpGetRoundMode().

## ◆ rb_thread_local_aset()

VALUE rb_thread_local_aset | ( | VALUE | thread,
|  | ID | id,
|  | VALUE | val
| ) |  |

Definition at line 3364 of file thread.c.

References OBJ_FROZEN, and rb_frozen_error_raise().

## ◆ rb_thread_main()

VALUE rb_thread_main | ( | void |  | ) |

Definition at line 2697 of file thread.c.

References GET_THREAD.

## ◆ rb_thread_reset_timer_thread()

void rb_thread_reset_timer_thread | ( | void |  | ) |

Definition at line 4425 of file thread.c.

## ◆ rb_thread_run()

VALUE rb_thread_run | ( | VALUE | thread | ) |

Definition at line 2587 of file thread.c.

References rb_thread_schedule(), and rb_thread_wakeup().

## ◆ rb_thread_schedule()

void rb_thread_schedule | ( | void |  | ) |

Definition at line 1408 of file thread.c.

Referenced by rb_thread_run().

## ◆ rb_thread_shield_destroy()

VALUE rb_thread_shield_destroy | ( | VALUE | self | ) |

Definition at line 4846 of file thread.c.

## ◆ rb_thread_shield_new()

VALUE rb_thread_shield_new | ( | void |  | ) |

Definition at line 4790 of file thread.c.

## ◆ rb_thread_shield_release()

VALUE rb_thread_shield_release | ( | VALUE | self | ) |

Definition at line 4835 of file thread.c.

## ◆ rb_thread_shield_wait()

VALUE rb_thread_shield_wait | ( | VALUE | self | ) |

Definition at line 4806 of file thread.c.

References GetThreadShieldPtr, and Qfalse.

## ◆ rb_thread_sleep()

void rb_thread_sleep | ( | int | sec | ) |

Definition at line 1385 of file thread.c.

References INT2FIX, rb_thread_wait_for(), and rb_time_timeval().

## ◆ rb_thread_sleep_deadly()

void rb_thread_sleep_deadly | ( | void |  | ) |

Definition at line 1321 of file thread.c.

References thread_debug.

Referenced by rb_thread_stop().

## ◆ rb_thread_sleep_forever()

void rb_thread_sleep_forever | ( | void |  | ) |

Definition at line 1314 of file thread.c.

References thread_debug.

## ◆ rb_thread_sleep_interruptible()

void rb_thread_sleep_interruptible | ( | void |  | ) |

Definition at line 1328 of file thread.c.

References rb_thread_struct::ec, GET_THREAD, RUBY_VM_CHECK_INTS_BLOCKING, rb_thread_struct::status, and THREAD_STOPPED.

## ◆ rb_thread_start_timer_thread()

void rb_thread_start_timer_thread | ( | void |  | ) |

Definition at line 4431 of file thread.c.

## ◆ rb_thread_stop()

VALUE rb_thread_stop | ( | void |  | ) |

Definition at line 2596 of file thread.c.

References Qnil, rb_eThreadError, rb_raise(), rb_thread_alone(), and rb_thread_sleep_deadly().

## ◆ rb_thread_stop_timer_thread()

void rb_thread_stop_timer_thread | ( | void |  | ) |

Definition at line 4417 of file thread.c.

## ◆ rb_thread_terminate_all()

void rb_thread_terminate_all | ( | void |  | ) |

Definition at line 559 of file thread.c.

References rb_thread_struct::ec, EC_EXEC_TAG, EC_PUSH_TAG, GET_THREAD, rb_vm_struct::main_thread, rb_bug(), rb_threadptr_unlock_all_locking_mutexes(), TAG_NONE, thread_debug, and rb_thread_struct::vm.

## ◆ rb_thread_to_be_killed()

int rb_thread_to_be_killed | ( | VALUE | thread | ) |

Definition at line 2472 of file thread.c.

## ◆ rb_thread_wait_fd()

void rb_thread_wait_fd | ( | int | fd | ) |

Definition at line 4042 of file thread.c.

Referenced by rb_io_read_check().

## ◆ rb_thread_wait_for()

void rb_thread_wait_for | ( | struct timeval | time | ) |

Definition at line 1347 of file thread.c.

References GET_THREAD.

Referenced by rb_thread_sleep().

## ◆ rb_thread_wakeup()

VALUE rb_thread_wakeup | ( | VALUE | thread | ) |

Definition at line 2540 of file thread.c.

References rb_eThreadError, rb_raise(), rb_thread_wakeup_alive(), and RTEST.

Referenced by rb_thread_run().

## ◆ rb_thread_wakeup_alive()

VALUE rb_thread_wakeup_alive | ( | VALUE | thread | ) |

Definition at line 2549 of file thread.c.

Referenced by rb_thread_wakeup().

## ◆ rb_threadptr_check_signal()

void rb_threadptr_check_signal | ( | rb_thread_t * | mth | ) |

Definition at line 4318 of file thread.c.

References rb_signal_buff_size().

## ◆ rb_threadptr_execute_interrupts()

MJIT_FUNC_EXPORTED int rb_threadptr_execute_interrupts | ( | rb_thread_t * | th,
|  | int | blocking_timing
| ) |  |

Definition at line 2194 of file thread.c.

References rb_thread_struct::ec, FALSE, and rb_execution_context_struct::raised_flag.

Referenced by rb_thread_execute_interrupts().

## ◆ rb_threadptr_interrupt()

void rb_threadptr_interrupt | ( | rb_thread_t * | th | ) |

Definition at line 510 of file thread.c.

Referenced by rb_notify_fd_close().

## ◆ rb_threadptr_pending_interrupt_clear()

void rb_threadptr_pending_interrupt_clear | ( | rb_thread_t * | th | ) |

Definition at line 1751 of file thread.c.

References rb_thread_struct::pending_interrupt_queue, and rb_ary_clear().

## ◆ rb_threadptr_pending_interrupt_enque()

void rb_threadptr_pending_interrupt_enque | ( | rb_thread_t * | th,
|  | VALUE | v
| ) |  |

Definition at line 1757 of file thread.c.

References rb_thread_struct::pending_interrupt_queue, rb_thread_struct::pending_interrupt_queue_checked, rb_ary_push(), and v.

Referenced by rb_fiber_start(), and rb_notify_fd_close().

## ◆ rb_threadptr_root_fiber_terminate()

void rb_threadptr_root_fiber_terminate | ( | rb_thread_t * | th | ) |

Definition at line 1898 of file cont.c.

References rb_thread_struct::ec, rb_execution_context_struct::fiber_ptr, FIBER_TERMINATED, and rb_ec_clear_vm_stack().

## ◆ rb_threadptr_signal_exit()

void rb_threadptr_signal_exit | ( | rb_thread_t * | th | ) |

Definition at line 2334 of file thread.c.

References argv, rb_eSystemExit, and rb_str_new2.

Referenced by rb_signal_exec().

## ◆ rb_threadptr_signal_raise()

void rb_threadptr_signal_raise | ( | rb_thread_t * | th,
|  | int | sig
| ) |  |

Definition at line 2324 of file thread.c.

References argv, INT2FIX, rb_eSignal, and sig.

Referenced by rb_signal_exec().

## ◆ rb_threadptr_unlock_all_locking_mutexes()

void rb_threadptr_unlock_all_locking_mutexes | ( | rb_thread_t * | th | ) |

Definition at line 542 of file thread.c.

References err, rb_thread_struct::keeping_mutexes, and rb_mutex_struct::next_mutex.

Referenced by rb_thread_terminate_all().

## ◆ rb_uninterruptible()

VALUE rb_uninterruptible | ( | VALUE(*)(VALUE) | b_proc,
|  | VALUE | data
| ) |  |

Definition at line 5554 of file thread.c.

References GET_THREAD, rb_cObject, rb_hash_aset(), and rb_ident_hash_new().

## ◆ rb_vm_gvl_destroy()

void rb_vm_gvl_destroy | ( | rb_vm_t * | vm | ) |

Definition at line 421 of file thread.c.

References rb_native_mutex_destroy(), rb_vm_struct::waitpid_lock, and rb_vm_struct::workqueue_lock.

## ◆ rb_vm_proc_local_ep()

const VALUE* rb_vm_proc_local_ep | ( | VALUE | proc | ) |

Definition at line 653 of file thread.c.

Referenced by rb_fiber_start().

## ◆ rb_wait_for_single_fd()

int rb_wait_for_single_fd | ( | int | fd,
|  | int | events,
|  | struct timeval * | tv
| ) |  |

Definition at line 4276 of file thread.c.

References select_args::as, select_args::fd, ptr, RB_WAITFD_IN, and select_args::read.

## ◆ ruby_sigchld_handler()

void ruby_sigchld_handler | ( | rb_vm_t * |  | ) |

Definition at line 1073 of file signal.c.

References GET_SIGCHLD_HIT, ruby_waitpid_all(), and SIGCHLD_LOSSY.

## ◆ ruby_thread_has_gvl_p()

int ruby_thread_has_gvl_p | ( | void |  | ) |

Definition at line 1705 of file thread.c.

References rb_thread_struct::blocking_region_buffer.

Referenced by rb_fatal().

## ◆ ruby_thread_init_stack()

void ruby_thread_init_stack | ( | rb_thread_t * | th | ) |

Definition at line 647 of file thread.c.

## ◆ STATIC_ASSERT()

STATIC_ASSERT | ( | THREAD_SHIELD_WAITING_MAX | ,
|  | THREAD_SHIELD_WAITING_MAX<= | UINT_MAX
| ) |  |

restore_fdset
#define restore_fdset(dst, src)
TRUE
#define TRUE
Definition: nkf.h:175
f
#define f
only_if_constant
#define only_if_constant(expr, notconst)
Definition: thread.c:186
rb_blocking_region_buffer
Definition: thread.c:152