Ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a25176072e02db9254f0e0c84c805cd)
|
#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 |
Enumerations | |
enum | SLEEP_FLAGS { SLEEP_DEADLOCKABLE = 0x1 , SLEEP_SPURIOUS_CHECK = 0x2 } |
enum | handle_interrupt_timing { INTERRUPT_NONE , INTERRUPT_IMMEDIATE , INTERRUPT_ON_BLOCKING , INTERRUPT_NEVER } |
#define BLOCKING_REGION | ( | th, | |
exec, | |||
ubf, | |||
ubfarg, | |||
fail_if_interrupted | |||
) |
#define do_select_update | ( | ) |
#define fd_init_copy | ( | f | ) |
#define GetThreadShieldPtr | ( | obj | ) | ((VALUE)rb_check_typeddata((obj), &thread_shield_data_type)) |
#define GVL_UNLOCK_BEGIN | ( | th | ) |
#define GVL_UNLOCK_END | ( | th | ) |
#define OBJ_ID_EQL | ( | obj_id, | |
other | |||
) | ((obj_id) == (other)) |
#define PRIu64 PRI_64_PREFIX "u" |
#define RB_GC_SAVE_MACHINE_CONTEXT | ( | th | ) |
#define rb_intern | ( | str | ) | rb_intern_const(str) |
#define RUBY_VM_CHECK_INTS_BLOCKING | ( | ec | ) | vm_check_ints_blocking(ec) |
#define THREAD_LOCAL_STORAGE_INITIALISED_P | ( | th | ) | RB_FL_TEST_RAW((th), THREAD_LOCAL_STORAGE_INITIALISED) |
#define THREAD_SHIELD_WAITING_MAX (THREAD_SHIELD_WAITING_MASK>>THREAD_SHIELD_WAITING_SHIFT) |
#define threadptr_initialized | ( | th | ) | ((th)->invoke_type != thread_invoke_type_none) |
enum SLEEP_FLAGS |
Definition at line 5161 of file thread.c.
References GET_THREAD.
NOINLINE | ( | rb_hrtime_t | rb_hrtime_nowvoid | ) |
NOINLINE | ( | static int | thread_start_func_2rb_thread_t *th, VALUE *stack_start | ) |
NORETURN | ( | static void | async_bug_fdconst char *mesg, int errno_arg, int fd | ) |
NORETURN | ( | static void | rb_threadptr_to_killrb_thread_t *th | ) |
Definition at line 4467 of file thread.c.
References rb_get_coverages(), rb_hash_foreach(), and RTEST.
Referenced by rb_reset_coverages().
Definition at line 5518 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().
void rb_ec_clear_current_thread_trace_func | ( | const rb_execution_context_t * | ec | ) |
Definition at line 274 of file vm_trace.c.
int rb_ec_reset_raised | ( | rb_execution_context_t * | ec | ) |
Definition at line 2353 of file thread.c.
References RAISED_EXCEPTION, and rb_execution_context_struct::raised_flag.
int rb_ec_set_raised | ( | rb_execution_context_t * | ec | ) |
Definition at line 2343 of file thread.c.
References RAISED_EXCEPTION, and rb_execution_context_struct::raised_flag.
Definition at line 5074 of file thread.c.
Referenced by rb_invcmp(), and rb_io_puts().
VALUE rb_exec_recursive_paired | ( | VALUE(*)(VALUE, VALUE, int) | func, |
VALUE | obj, | ||
VALUE | paired_obj, | ||
VALUE | arg | ||
) |
Definition at line 5085 of file thread.c.
Referenced by rb_ary_cmp().
Definition at line 5476 of file thread.c.
References GET_VM.
Referenced by rb_clear_coverages(), and rb_iseq_new_top().
rb_hrtime_t rb_hrtime_now | ( | void | ) |
void rb_nativethread_lock_destroy | ( | rb_nativethread_lock_t * | lock | ) |
Definition at line 434 of file thread.c.
References rb_native_mutex_destroy().
void rb_nativethread_lock_initialize | ( | rb_nativethread_lock_t * | lock | ) |
Definition at line 428 of file thread.c.
References rb_native_mutex_initialize().
void rb_nativethread_lock_lock | ( | rb_nativethread_lock_t * | lock | ) |
Definition at line 440 of file thread.c.
References rb_native_mutex_lock().
Referenced by rb_grantpt(), and rb_workqueue_register().
void rb_nativethread_lock_unlock | ( | rb_nativethread_lock_t * | lock | ) |
Definition at line 446 of file thread.c.
References rb_native_mutex_unlock().
Referenced by rb_grantpt(), and rb_workqueue_register().
void * rb_nogvl | ( | void *(*)(void *) | func, |
void * | data1, | ||
rb_unblock_function_t * | ubf, | ||
void * | data2, | ||
int | flags | ||
) |
Definition at line 1451 of file thread.c.
References GET_EC.
Referenced by rb_thread_call_without_gvl(), and rb_thread_call_without_gvl2().
Definition at line 2363 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.
Definition at line 5503 of file thread.c.
References GET_VM, Qfalse, rb_clear_coverages(), rb_iseq_remove_coverage_all(), and rb_remove_event_hook().
const rb_method_entry_t * rb_resolve_me_location | ( | const rb_method_entry_t * | me, |
VALUE | resolved_location[5] | ||
) |
Definition at line 5399 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.
Definition at line 1026 of file process.c.
References rb_native_mutex_lock(), and rb_vm_struct::waitpid_lock.
Definition at line 3491 of file thread.c.
Referenced by rb_thread_stop().
Definition at line 1661 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().
void * rb_thread_call_without_gvl | ( | void *(*)(void *data) | func, |
void * | data1, | ||
rb_unblock_function_t * | ubf, | ||
void * | data2 | ||
) |
Definition at line 1587 of file thread.c.
References rb_nogvl().
void * rb_thread_call_without_gvl2 | ( | void *(*)(void *) | func, |
void * | data1, | ||
rb_unblock_function_t * | ubf, | ||
void * | data2 | ||
) |
Definition at line 1580 of file thread.c.
References rb_nogvl(), and RB_NOGVL_INTR_FAIL.
Definition at line 1361 of file thread.c.
References GET_EC, and RUBY_VM_CHECK_INTS_BLOCKING.
Definition at line 1371 of file thread.c.
References rb_signal_buff_size().
Definition at line 965 of file thread.c.
Referenced by rb_detach_process().
Definition at line 2675 of file thread.c.
References GET_THREAD.
Referenced by VpGetPrecLimit(), and VpGetRoundMode().
Definition at line 2283 of file thread.c.
References rb_threadptr_execute_interrupts().
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 1378 of file thread.c.
References RUBY_VM_INTERRUPTED.
VALUE rb_thread_io_blocking_region | ( | rb_blocking_function_t * | func, |
void * | data1, | ||
int | fd | ||
) |
Definition at line 1594 of file thread.c.
References waiting_fd::fd, GET_EC, Qundef, and waiting_fd::th.
Definition at line 2629 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.
Definition at line 3215 of file thread.c.
Referenced by VpGetPrecLimit(), and VpGetRoundMode().
Definition at line 3363 of file thread.c.
References OBJ_FROZEN, and rb_frozen_error_raise().
Definition at line 2696 of file thread.c.
References GET_THREAD.
Definition at line 2586 of file thread.c.
References rb_thread_schedule(), and rb_thread_wakeup().
Definition at line 1407 of file thread.c.
Referenced by rb_thread_run().
Definition at line 4805 of file thread.c.
References GetThreadShieldPtr, and Qfalse.
Definition at line 1384 of file thread.c.
References INT2FIX, rb_thread_wait_for(), and rb_time_timeval().
Definition at line 1313 of file thread.c.
References thread_debug.
Definition at line 1327 of file thread.c.
References rb_thread_struct::ec, GET_THREAD, RUBY_VM_CHECK_INTS_BLOCKING, rb_thread_struct::status, and THREAD_STOPPED.
Definition at line 2595 of file thread.c.
References Qnil, rb_eThreadError, rb_raise(), rb_thread_alone(), and rb_thread_sleep_deadly().
Definition at line 554 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.
Definition at line 4041 of file thread.c.
Referenced by rb_io_read_check().
Definition at line 2539 of file thread.c.
References rb_eThreadError, rb_raise(), rb_thread_wakeup_alive(), and RTEST.
Referenced by rb_thread_run().
Definition at line 2548 of file thread.c.
Referenced by rb_thread_wakeup().
void rb_threadptr_check_signal | ( | rb_thread_t * | mth | ) |
Definition at line 4317 of file thread.c.
References rb_signal_buff_size().
MJIT_FUNC_EXPORTED int rb_threadptr_execute_interrupts | ( | rb_thread_t * | th, |
int | blocking_timing | ||
) |
Definition at line 2193 of file thread.c.
References rb_thread_struct::ec, FALSE, and rb_execution_context_struct::raised_flag.
Referenced by rb_thread_execute_interrupts().
void rb_threadptr_interrupt | ( | rb_thread_t * | th | ) |
Definition at line 505 of file thread.c.
Referenced by rb_notify_fd_close().
void rb_threadptr_pending_interrupt_clear | ( | rb_thread_t * | th | ) |
Definition at line 1750 of file thread.c.
References rb_thread_struct::pending_interrupt_queue, and rb_ary_clear().
void rb_threadptr_pending_interrupt_enque | ( | rb_thread_t * | th, |
VALUE | v | ||
) |
Definition at line 1756 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().
void rb_threadptr_root_fiber_terminate | ( | rb_thread_t * | th | ) |
Definition at line 1912 of file cont.c.
References rb_thread_struct::ec, rb_execution_context_struct::fiber_ptr, FIBER_TERMINATED, and rb_ec_clear_vm_stack().
void rb_threadptr_signal_exit | ( | rb_thread_t * | th | ) |
Definition at line 2333 of file thread.c.
References argv, rb_eSystemExit, and rb_str_new2.
Referenced by rb_signal_exec().
void rb_threadptr_signal_raise | ( | rb_thread_t * | th, |
int | sig | ||
) |
Definition at line 2323 of file thread.c.
References argv, INT2FIX, rb_eSignal, and sig.
Referenced by rb_signal_exec().
void rb_threadptr_unlock_all_locking_mutexes | ( | rb_thread_t * | th | ) |
Definition at line 537 of file thread.c.
References err, rb_thread_struct::keeping_mutexes, and rb_mutex_struct::next_mutex.
Referenced by rb_thread_terminate_all().
Definition at line 5553 of file thread.c.
References GET_THREAD, rb_cObject, rb_hash_aset(), and rb_ident_hash_new().
Definition at line 648 of file thread.c.
Referenced by rb_fiber_start().
Definition at line 4275 of file thread.c.
References select_args::as, select_args::fd, ptr, RB_WAITFD_IN, and select_args::read.
Definition at line 1073 of file signal.c.
References GET_SIGCHLD_HIT, ruby_waitpid_all(), and SIGCHLD_LOSSY.
Definition at line 1704 of file thread.c.
References rb_thread_struct::blocking_region_buffer.
Referenced by rb_fatal().
void ruby_thread_init_stack | ( | rb_thread_t * | th | ) |
STATIC_ASSERT | ( | THREAD_SHIELD_WAITING_MAX | , |
THREAD_SHIELD_WAITING_MAX<= | UINT_MAX | ||
) |