Ruby 1.9.2p136(2010-12-25revision30365)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Defines | Typedefs | Functions | Variables

# thread.c File Reference

`#include "eval_intern.h"`
`#include "gc.h"`
Include dependency graph for thread.c:

Go to the source code of this file.

## Data Structures
struct | rb_blocking_region_buffer
struct | rb_mutex_struct
struct | join_arg
struct | thgroup
struct | thgroup_list_params
struct | exec_recursive_params
struct | call_trace_func_args
## Defines
#define | USE_NATIVE_THREAD_PRIORITY 0
#define | RUBY_THREAD_PRIORITY_MAX 3
#define | RUBY_THREAD_PRIORITY_MIN -3
#define | THREAD_DEBUG 0
#define | THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION
#define | RB_GC_SAVE_MACHINE_CONTEXT(th)
#define | GVL_UNLOCK_BEGIN()
#define | GVL_UNLOCK_END()
#define | BLOCKING_REGION_CORE(exec)
#define | blocking_region_begin(th, region, func, arg)
#define | BLOCKING_REGION(exec, ubf, ubfarg)
#define | thread_debug if(0)printf
#define | thread_start_func_2(th, st, rst) thread_start_func_2(th, st)
#define | DELAY_INFTY 1E30
#define | GetMutexPtr(obj, tobj) TypedData_Get_Struct(obj, mutex_t, &mutex_data_type, tobj)
#define | mutex_mark NULL
#define | GetBarrierPtr(obj) (VALUE)rb_check_typeddata(obj, &barrier_data_type)
#define | rb_intern(str) rb_intern_const(str)
## Typedefs
typedef struct rb_mutex_struct | mutex_t
## Functions
static void | sleep_timeval (rb_thread_t *th, struct timeval time)
static void | sleep_wait_for_interrupt (rb_thread_t *th, double sleepsec)
static void | sleep_forever (rb_thread_t *th, int nodeadlock)
static double | timeofday (void)
struct timeval | rb_time_interval (VALUE)
static int | rb_threadptr_dead (rb_thread_t *th)
static void | rb_check_deadlock (rb_vm_t *vm)
int | rb_signal_buff_size (void)
void | rb_signal_exec (rb_thread_t *th, int sig)
void | rb_disable_interrupt (void)
void | rb_thread_stop_timer_thread (void)
static void | st_delete_wrap (st_table *table, st_data_t key)
static void | set_unblock_function (rb_thread_t *th, rb_unblock_function_t *func, void *arg, struct rb_unblock_callback *old)
static void | reset_unblock_function (rb_thread_t *th, const struct rb_unblock_callback *old)
static void | blocking_region_end (rb_thread_t *th, struct rb_blocking_region_buffer *region)
| NOINLINE (static int thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_start))
static void | timer_thread_function (void *)
void | rb_thread_lock_unlock (rb_thread_lock_t *lock)
void | rb_thread_lock_destroy (rb_thread_lock_t *lock)
void | rb_threadptr_interrupt (rb_thread_t *th)
static int | terminate_i (st_data_t key, st_data_t val, rb_thread_t *main_thread)
static void | rb_mutex_unlock_all (mutex_t *mutex, rb_thread_t *th)
static void | rb_mutex_abandon_all (mutex_t *mutexes)
void | rb_thread_terminate_all (void)
static void | thread_unlock_all_locking_mutexes (rb_thread_t *th)
static void | thread_cleanup_func_before_exec (void *th_ptr)
static void | thread_cleanup_func (void *th_ptr)
void | ruby_error_print (void)
static VALUE | rb_threadptr_raise (rb_thread_t *, int, VALUE *)
void | rb_thread_recycle_stack_release (VALUE *)
void | ruby_thread_init_stack (rb_thread_t *th)
static int | thread_start_func_2 (rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_start)
static VALUE | thread_create_core (VALUE thval, VALUE args, VALUE(*fn)(ANYARGS))
static VALUE | thread_s_new (int argc, VALUE *argv, VALUE klass)
static VALUE | thread_start (VALUE klass, VALUE args)
static VALUE | thread_initialize (VALUE thread, VALUE args)
VALUE | rb_thread_create (VALUE(*fn)(ANYARGS), void *arg)
static VALUE | remove_from_join_list (VALUE arg)
static VALUE | thread_join_sleep (VALUE arg)
static VALUE | thread_join (rb_thread_t *target_th, double delay)
static VALUE | thread_join_m (int argc, VALUE *argv, VALUE self)
static VALUE | thread_value (VALUE self)
static struct timeval | double2timeval (double d)
static void | getclockofday (struct timeval *tp)
void | rb_thread_sleep_forever (void)
static void | rb_thread_sleep_deadly (void)
static void | sleep_for_polling (rb_thread_t *th)
void | rb_thread_wait_for (struct timeval time)
void | rb_thread_polling (void)
void | rb_thread_check_ints (void)
int | rb_thread_check_trap_pending (void)
int | rb_thread_interrupted (VALUE thval)
struct timeval | rb_time_timeval (VALUE)
void | rb_thread_sleep (int sec)
static void | rb_threadptr_execute_interrupts_rec (rb_thread_t *, int)
static void | rb_thread_schedule_rec (int sched_depth)
void | rb_thread_schedule (void)
struct rb_blocking_region_buffer * | rb_thread_blocking_region_begin (void)
void | rb_thread_blocking_region_end (struct rb_blocking_region_buffer *region)
VALUE | rb_thread_blocking_region (rb_blocking_function_t *func, void *data1, rb_unblock_function_t *ubf, void *data2)
VALUE | rb_thread_call_without_gvl (rb_blocking_function_t *func, void *data1, rb_unblock_function_t *ubf, void *data2)
void * | rb_thread_call_with_gvl (void *(*func)(void *), void *data1)
int | ruby_thread_has_gvl_p (void)
static VALUE | thread_s_pass (VALUE klass)
void | rb_threadptr_execute_interrupts (rb_thread_t *th)
void | rb_gc_mark_threads (void)
static void | rb_threadptr_ready (rb_thread_t *th)
void | rb_threadptr_signal_raise (rb_thread_t *th, int sig)
void | rb_threadptr_signal_exit (rb_thread_t *th)
void | ruby_thread_stack_overflow (rb_thread_t *th)
int | rb_threadptr_set_raised (rb_thread_t *th)
int | rb_threadptr_reset_raised (rb_thread_t *th)
void | rb_thread_fd_close (int fd)
static VALUE | thread_raise_m (int argc, VALUE *argv, VALUE self)
VALUE | rb_thread_kill (VALUE thread)
static VALUE | rb_thread_s_kill (VALUE obj, VALUE th)
static VALUE | rb_thread_exit (void)
VALUE | rb_thread_wakeup (VALUE thread)
VALUE | rb_thread_run (VALUE thread)
VALUE | rb_thread_stop (void)
static int | thread_list_i (st_data_t key, st_data_t val, void *data)
VALUE | rb_thread_list (void)
VALUE | rb_thread_current (void)
static VALUE | thread_s_current (VALUE klass)
VALUE | rb_thread_main (void)
static VALUE | rb_thread_s_main (VALUE klass)
static VALUE | rb_thread_s_abort_exc (void)
static VALUE | rb_thread_s_abort_exc_set (VALUE self, VALUE val)
static VALUE | rb_thread_abort_exc (VALUE thread)
static VALUE | rb_thread_abort_exc_set (VALUE thread, VALUE val)
VALUE | rb_thread_group (VALUE thread)
static const char * | thread_status_name (enum rb_thread_status status)
static VALUE | rb_thread_status (VALUE thread)
static VALUE | rb_thread_alive_p (VALUE thread)
static VALUE | rb_thread_stop_p (VALUE thread)
static VALUE | rb_thread_safe_level (VALUE thread)
static VALUE | rb_thread_inspect (VALUE thread)
VALUE | rb_thread_local_aref (VALUE thread, ID id)
static VALUE | rb_thread_aref (VALUE thread, VALUE id)
VALUE | rb_thread_local_aset (VALUE thread, ID id, VALUE val)
static VALUE | rb_thread_aset (VALUE self, VALUE id, VALUE val)
static VALUE | rb_thread_key_p (VALUE self, VALUE key)
static int | thread_keys_i (ID key, VALUE value, VALUE ary)
static int | vm_living_thread_num (rb_vm_t *vm)
int | rb_thread_alone (void)
static VALUE | rb_thread_keys (VALUE self)
static VALUE | rb_thread_priority (VALUE thread)
static VALUE | rb_thread_priority_set (VALUE thread, VALUE prio)
static int | do_select (int n, fd_set *read, fd_set *write, fd_set *except, struct timeval *timeout)
static void | rb_thread_wait_fd_rw (int fd, int read)
void | rb_thread_wait_fd (int fd)
int | rb_thread_fd_writable (int fd)
int | rb_thread_select (int max, fd_set *read, fd_set *write, fd_set *except, struct timeval *timeout)
int | rb_thread_fd_select (int max, rb_fdset_t *read, rb_fdset_t *write, rb_fdset_t *except, struct timeval *timeout)
void | rb_gc_set_stack_end (VALUE **stack_end_p)
void | rb_gc_save_machine_context (rb_thread_t *th)
int | rb_get_next_signal (void)
void | rb_threadptr_check_signal (rb_thread_t *mth)
void | rb_thread_reset_timer_thread (void)
void | rb_thread_start_timer_thread (void)
static int | clear_coverage_i (st_data_t key, st_data_t val, st_data_t dummy)
static void | clear_coverage (void)
static void | rb_thread_atfork_internal (int(*atfork)(st_data_t, st_data_t, st_data_t))
static int | terminate_atfork_i (st_data_t key, st_data_t val, st_data_t current_th)
void | rb_thread_atfork (void)
static int | terminate_atfork_before_exec_i (st_data_t key, st_data_t val, st_data_t current_th)
void | rb_thread_atfork_before_exec (void)
static size_t | thgroup_memsize (const void *ptr)
static VALUE | thgroup_s_alloc (VALUE klass)
static int | thgroup_list_i (st_data_t key, st_data_t val, st_data_t data)
static VALUE | thgroup_list (VALUE group)
static VALUE | thgroup_enclose (VALUE group)
static VALUE | thgroup_enclosed_p (VALUE group)
static VALUE | thgroup_add (VALUE group, VALUE thread)
static const char * | mutex_unlock (mutex_t *mutex, rb_thread_t volatile *th)
static void | mutex_free (void *ptr)
static size_t | mutex_memsize (const void *ptr)
static VALUE | mutex_alloc (VALUE klass)
static VALUE | mutex_initialize (VALUE self)
VALUE | rb_mutex_new (void)
VALUE | rb_mutex_locked_p (VALUE self)
static void | mutex_locked (rb_thread_t *th, VALUE self)
VALUE | rb_mutex_trylock (VALUE self)
static int | lock_func (rb_thread_t *th, mutex_t *mutex, int last_thread)
static void | lock_interrupt (void *ptr)
VALUE | rb_mutex_lock (VALUE self)
VALUE | rb_mutex_unlock (VALUE self)
static VALUE | rb_mutex_sleep_forever (VALUE time)
static VALUE | rb_mutex_wait_for (VALUE time)
VALUE | rb_mutex_sleep (VALUE self, VALUE timeout)
static VALUE | mutex_sleep (int argc, VALUE *argv, VALUE self)
VALUE | rb_mutex_synchronize (VALUE mutex, VALUE(*func)(VALUE arg), VALUE arg)
static void | barrier_mark (void *ptr)
static VALUE | barrier_alloc (VALUE klass)
VALUE | rb_barrier_new (void)
VALUE | rb_barrier_wait (VALUE self)
VALUE | rb_barrier_release (VALUE self)
VALUE | rb_barrier_destroy (VALUE self)
static VALUE | recursive_list_access (void)
static VALUE | recursive_check (VALUE list, VALUE obj_id, VALUE paired_obj_id)
static void | recursive_push (VALUE list, VALUE obj, VALUE paired_obj)
static void | recursive_pop (VALUE list, VALUE obj, VALUE paired_obj)
static VALUE | exec_recursive_i (VALUE tag, struct exec_recursive_params *p)
static VALUE | exec_recursive (VALUE(*func)(VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE arg, int outer)
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)
static rb_event_hook_t * | alloc_event_hook (rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
static void | thread_reset_event_flags (rb_thread_t *th)
static void | rb_threadptr_add_event_hook (rb_thread_t *th, rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
static rb_thread_t * | thval2thread_t (VALUE thval)
void | rb_thread_add_event_hook (VALUE thval, rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
static int | set_threads_event_flags_i (st_data_t key, st_data_t val, st_data_t flag)
static void | set_threads_event_flags (int flag)
static void | exec_event_hooks (const rb_event_hook_t *hook, rb_event_flag_t flag, VALUE self, ID id, VALUE klass)
void | rb_threadptr_exec_event_hooks (rb_thread_t *th, rb_event_flag_t flag, VALUE self, ID id, VALUE klass)
void | rb_add_event_hook (rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
static int | remove_event_hook (rb_event_hook_t **root, rb_event_hook_func_t func)
static int | rb_threadptr_revmove_event_hook (rb_thread_t *th, rb_event_hook_func_t func)
int | rb_thread_remove_event_hook (VALUE thval, rb_event_hook_func_t func)
int | rb_remove_event_hook (rb_event_hook_func_t func)
static int | clear_trace_func_i (st_data_t key, st_data_t val, st_data_t flag)
void | rb_clear_trace_func (void)
static void | call_trace_func (rb_event_flag_t, VALUE data, VALUE self, ID id, VALUE klass)
static VALUE | set_trace_func (VALUE obj, VALUE trace)
static void | thread_add_trace_func (rb_thread_t *th, VALUE trace)
static VALUE | thread_add_trace_func_m (VALUE obj, VALUE trace)
static VALUE | thread_set_trace_func_m (VALUE obj, VALUE trace)
static const char * | get_event_name (rb_event_flag_t event)
VALUE | ruby_suppress_tracing (VALUE(*func)(VALUE, int), VALUE arg, int always)
static VALUE | call_trace_proc (VALUE args, int tracing)
VALUE | rb_thread_backtrace (VALUE thval)
static VALUE | rb_thread_backtrace_m (VALUE thval)
void | Init_Thread (void)
int | ruby_native_thread_p (void)
static int | check_deadlock_i (st_data_t key, st_data_t val, int *found)
static void | update_coverage (rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klass)
VALUE | rb_get_coverages (void)
void | rb_set_coverages (VALUE coverages)
void | rb_reset_coverages (void)
## Variables
VALUE | rb_cMutex
VALUE | rb_cBarrier
static const VALUE | eKillSignal = INT2FIX(0)
static const VALUE | eTerminateSignal = INT2FIX(1)
static volatile int | system_working = 1
static const rb_data_type_t | thgroup_data_type
static const rb_data_type_t | mutex_data_type
static const rb_data_type_t | barrier_data_type
static ID | recursive_key

## Define Documentation

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

Value:

    do { \
        rb_thread_t *__th = GET_THREAD(); \
        struct rb_blocking_region_buffer __region; \
        blocking_region_begin(__th, &__region, ubf, ubfarg); \
        exec; \
        blocking_region_end(__th, &__region); \
        RUBY_VM_CHECK_INTS(); \
    } while(0)

Definition at line 136 of file thread.c.

Referenced by do_select(), and rb_thread_blocking_region().

#define blocking_region_begin | ( |  | th,
|  |  | region,
|  |  | func,
|  |  | arg
| ) |  |

Value:

    do { \
        (region)->prev_status = (th)->status; \
        set_unblock_function((th), (func), (arg), &(region)->oldubf); \
        (th)->blocking_region_buffer = (region); \
        (th)->status = THREAD_STOPPED; \
        thread_debug("enter blocking region (%p)\n", (void *)(th)); \
        RB_GC_SAVE_MACHINE_CONTEXT(th); \
        native_mutex_unlock(&(th)->vm->global_vm_lock); \
      } while (0)

Definition at line 125 of file thread.c.

Referenced by rb_thread_blocking_region_begin(), and rb_thread_call_with_gvl().

#define BLOCKING_REGION_CORE | ( |  | exec | ) |

Value:

    do { \
        GVL_UNLOCK_BEGIN(); {\
                exec; \
        } \
        GVL_UNLOCK_END(); \
    } while(0);

Definition at line 118 of file thread.c.

Referenced by rb_mutex_lock().

#define DELAY_INFTY 1E30

Definition at line 634 of file thread.c.

Referenced by thread_join(), thread_join_m(), and thread_value().

#define GetBarrierPtr | ( |  | obj | ) | (VALUE)rb_check_typeddata(obj, &barrier_data_type)

Definition at line 3436 of file thread.c.

Referenced by rb_barrier_destroy(), rb_barrier_release(), and rb_barrier_wait().

#define GetMutexPtr | ( |  | obj,
|  |  | tobj
| ) |  | TypedData_Get_Struct(obj, mutex_t, &mutex_data_type, tobj)

Definition at line 3025 of file thread.c.

Referenced by check_deadlock_i(), mutex_locked(), rb_barrier_wait(), rb_mutex_lock(), rb_mutex_locked_p(), rb_mutex_trylock(), and rb_mutex_unlock().

#define GVL_UNLOCK_BEGIN | ( |  | ) |

Value:

    do { \
      rb_thread_t *_th_stored = GET_THREAD(); \
      RB_GC_SAVE_MACHINE_CONTEXT(_th_stored); \
      native_mutex_unlock(&_th_stored->vm->global_vm_lock)

Definition at line 108 of file thread.c.

#define GVL_UNLOCK_END | ( |  | ) |

Value:

    native_mutex_lock(&_th_stored->vm->global_vm_lock); \
      rb_thread_set_current(_th_stored); \
    } while(0)

Definition at line 113 of file thread.c.

#define mutex_mark NULL

Definition at line 3030 of file thread.c.

#define RB_GC_SAVE_MACHINE_CONTEXT | ( |  | th | ) |

Value:

    do { \
        rb_gc_save_machine_context(th); \
        SET_MACHINE_STACK_END(&(th)->machine_stack_end); \
      } while (0)

Definition at line 102 of file thread.c.

Referenced by rb_thread_schedule_rec().

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

#define RUBY_THREAD_PRIORITY_MAX 3

Definition at line 52 of file thread.c.

Referenced by rb_thread_priority_set().

#define RUBY_THREAD_PRIORITY_MIN -3

Definition at line 53 of file thread.c.

Referenced by rb_thread_priority_set().

#define thread_debug if(0)printf

Definition at line 193 of file thread.c.

Referenced by blocking_region_end(), rb_thread_alone(), rb_thread_kill(), rb_thread_schedule_rec(), rb_thread_sleep_deadly(), rb_thread_sleep_forever(), rb_thread_terminate_all(), rb_thread_wait_fd_rw(), rb_threadptr_check_signal(), rb_threadptr_execute_interrupts_rec(), sleep_timeval(), terminate_i(), thread_join(), thread_join_sleep(), and thread_start_func_2().

#define THREAD_DEBUG 0

Definition at line 57 of file thread.c.

#define thread_start_func_2 | ( |  | th,
|  |  | st,
|  |  | rst
| ) |  | thread_start_func_2(th, st)

Definition at line 197 of file thread.c.

#define THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION

Definition at line 89 of file thread.c.

#define USE_NATIVE_THREAD_PRIORITY 0

Definition at line 51 of file thread.c.

## Typedef Documentation

typedef struct rb_mutex_struct mutex_t

## Function Documentation

static rb_event_hook_t* alloc_event_hook | ( | rb_event_hook_func_t | func,
|  | rb_event_flag_t | events,
|  | VALUE | data
| ) |  | `[static]`

Definition at line 3705 of file thread.c.

References ALLOC, rb_event_hook_struct::data, rb_event_hook_struct::flag, func, and rb_event_hook_struct::func.

Referenced by rb_add_event_hook(), and rb_threadptr_add_event_hook().

static VALUE barrier_alloc | ( | VALUE | klass | ) | `[static]`

Definition at line 3431 of file thread.c.

References mutex_alloc(), and TypedData_Wrap_Struct.

Referenced by rb_barrier_new().

static void barrier_mark | ( | void * | ptr | ) | `[static]`

Definition at line 3420 of file thread.c.

References rb_gc_mark().

static void blocking_region_end | ( | rb_thread_t * | th,
|  | struct rb_blocking_region_buffer * | region
| ) |  | `[inline, static]`

Definition at line 1034 of file thread.c.

References rb_vm_struct::global_vm_lock, rb_blocking_region_buffer::oldubf, rb_blocking_region_buffer::prev_status, rb_thread_set_current, reset_unblock_function(), thread_debug, THREAD_STOPPED, and rb_thread_struct::vm.

Referenced by rb_thread_blocking_region_end(), and rb_thread_call_with_gvl().

static void call_trace_func | ( | rb_event_flag_t | event,
|  | VALUE | data,
|  | VALUE | self,
|  | ID | id,
|  | VALUE | klass
| ) |  | `[static]`

Definition at line 4075 of file thread.c.

References call_trace_proc(), call_trace_func_args::event, FALSE, id, call_trace_func_args::id, call_trace_func_args::klass, call_trace_func_args::proc, ruby_suppress_tracing(), and call_trace_func_args::self.

Referenced by set_trace_func(), thread_add_trace_func(), and thread_set_trace_func_m().

static VALUE call_trace_proc | ( | VALUE | args,
|  | int | tracing
| ) |  | `[static]`

Definition at line 4034 of file thread.c.

References argv, call_trace_func_args::event, FL_SINGLETON, FL_TEST, get_event_name(), GET_THREAD, call_trace_func_args::id, ID2SYM, ID_ALLOCATOR, INT2FIX, call_trace_func_args::klass, call_trace_func_args::proc, Qnil, rb_binding_new(), rb_iv_get(), rb_proc_call_with_block(), rb_sourcefile(), rb_sourceline(), rb_str_new2(), rb_thread_method_id_and_class(), RBASIC, RUBY_EVENT_C_CALL, RUBY_EVENT_C_RETURN, call_trace_func_args::self, T_ICLASS, and TYPE.

Referenced by call_trace_func().

static int check_deadlock_i | ( | st_data_t | key,
|  | st_data_t | val,
|  | int * | found
| ) |  | `[static]`

Definition at line 4272 of file thread.c.

References rb_mutex_struct::cond_notified, GetMutexPtr, GetThreadPtr, rb_mutex_struct::lock, rb_thread_struct::locking_mutex, RUBY_VM_INTERRUPTED, ST_CONTINUE, ST_STOP, rb_thread_struct::status, rb_mutex_struct::th, THREAD_STOPPED_FOREVER, and rb_thread_struct::transition_for_lock.

Referenced by rb_check_deadlock().

static void clear_coverage | ( | void |  | ) | `[static]`

Definition at line 2736 of file thread.c.

References clear_coverage_i(), rb_get_coverages(), RHASH_TBL, RTEST, and st_foreach.

Referenced by rb_thread_atfork_internal().

static int clear_coverage_i | ( | st_data_t | key,
|  | st_data_t | val,
|  | st_data_t | dummy
| ) |  | `[static]`

Definition at line 2722 of file thread.c.

References INT2FIX, Qnil, RARRAY_LEN, RARRAY_PTR, and ST_CONTINUE.

Referenced by clear_coverage().

static int clear_trace_func_i | ( | st_data_t | key,
|  | st_data_t | val,
|  | st_data_t | flag
| ) |  | `[static]`

Definition at line 3870 of file thread.c.

References GetThreadPtr, rb_threadptr_revmove_event_hook(), and ST_CONTINUE.

Referenced by rb_clear_trace_func().

static int do_select | ( | int | n,
|  | fd_set * | read,
|  | fd_set * | write,
|  | fd_set * | except,
|  | struct timeval * | timeout
| ) |  | `[static]`

Definition at line 2431 of file thread.c.

References BLOCKING_REGION, errno, GET_THREAD, gettimeofday(), NULL, result, timeofday(), timeval::tv_sec, timeval::tv_usec, UNINITIALIZED_VAR, and wait().

Referenced by rb_thread_fd_select(), rb_thread_select(), and rb_thread_wait_fd_rw().

static struct timeval double2timeval | ( | double | d | ) | `[static, read]`

Definition at line 814 of file thread.c.

References timeval::tv_sec, and timeval::tv_usec.

Referenced by sleep_wait_for_interrupt().

static void exec_event_hooks | ( | const rb_event_hook_t * | hook,
|  | rb_event_flag_t | flag,
|  | VALUE | self,
|  | ID | id,
|  | VALUE | klass
| ) |  | `[inline, static]`

Definition at line 3775 of file thread.c.

References rb_event_hook_struct::data, rb_event_hook_struct::flag, rb_event_hook_struct::func, and rb_event_hook_struct::next.

Referenced by rb_threadptr_exec_event_hooks().

static VALUE exec_recursive | ( | VALUE(*)(VALUE, VALUE, int) | func,
|  | VALUE | obj,
|  | VALUE | pairid,
|  | VALUE | arg,
|  | int | outer
| ) |  | `[static]`

Definition at line 3632 of file thread.c.

References exec_recursive_params::arg, exec_recursive_i(), exec_recursive_params::func, func, ID2SYM, exec_recursive_params::list, exec_recursive_params::obj, exec_recursive_params::objid, exec_recursive_params::pairid, Qundef, rb_catch_obj(), rb_obj_id(), rb_throw_obj(), recursive_check(), recursive_list_access(), recursive_pop(), recursive_push(), result, and TRUE.

Referenced by rb_exec_recursive(), rb_exec_recursive_outer(), and rb_exec_recursive_paired().

static VALUE exec_recursive_i | ( | VALUE | tag,
|  | struct exec_recursive_params * | p
| ) |  | `[static]`

Definition at line 3603 of file thread.c.

References exec_recursive_params::arg, EXEC_TAG, FALSE, exec_recursive_params::func, JUMP_TAG, exec_recursive_params::list, exec_recursive_params::obj, exec_recursive_params::objid, exec_recursive_params::pairid, POP_TAG, PUSH_TAG, Qundef, recursive_pop(), recursive_push(), and result.

Referenced by exec_recursive().

static const char* get_event_name | ( | rb_event_flag_t | event | ) | `[static]`

Definition at line 3999 of file thread.c.

References RUBY_EVENT_C_CALL, RUBY_EVENT_C_RETURN, RUBY_EVENT_CALL, RUBY_EVENT_CLASS, RUBY_EVENT_END, RUBY_EVENT_LINE, RUBY_EVENT_RAISE, and RUBY_EVENT_RETURN.

Referenced by call_trace_proc().

static void getclockofday | ( | struct timeval * | tp | ) | `[static]`

Definition at line 848 of file thread.c.

References gettimeofday(), NULL, timespec::tv_nsec, timespec::tv_sec, timeval::tv_sec, and timeval::tv_usec.

Referenced by sleep_timeval().

void Init_Thread | ( | void |  | ) |

Definition at line 4165 of file thread.c.

References GET_THREAD, mutex_alloc(), mutex_initialize(), mutex_sleep(), rb_cMutex, rb_cObject, rb_cThread, rb_define_alloc_func(), rb_define_class(), rb_define_const(), rb_define_global_function(), rb_define_method(), rb_define_singleton_method(), rb_eStandardError, rb_eThreadError, rb_intern, rb_mutex_lock(), rb_mutex_locked_p(), rb_mutex_trylock(), rb_mutex_unlock(), rb_obj_alloc(), rb_thread_abort_exc(), rb_thread_abort_exc_set(), rb_thread_alive_p(), rb_thread_aref(), rb_thread_aset(), rb_thread_backtrace_m(), rb_thread_exit(), rb_thread_group(), rb_thread_inspect(), rb_thread_key_p(), rb_thread_keys(), rb_thread_kill(), rb_thread_list(), rb_thread_priority(), rb_thread_priority_set(), rb_thread_run(), rb_thread_s_abort_exc(), rb_thread_s_abort_exc_set(), rb_thread_s_kill(), rb_thread_s_main(), rb_thread_safe_level(), rb_thread_stop(), rb_thread_stop_p(), rb_thread_wakeup(), set_trace_func(), rb_thread_struct::thgroup, thgroup_add(), rb_vm_struct::thgroup_default, thgroup_enclose(), thgroup_enclosed_p(), thgroup_list(), thgroup_s_alloc(), thread_add_trace_func_m(), thread_initialize(), thread_join_m(), thread_raise_m(), thread_s_current(), thread_s_new(), thread_s_pass(), thread_set_trace_func_m(), thread_start(), thread_value(), and rb_thread_struct::vm.

static int lock_func | ( | rb_thread_t * | th,
|  | mutex_t * | mutex,
|  | int | last_thread
| ) |  | `[static]`

Definition at line 3142 of file thread.c.

References rb_mutex_struct::cond, rb_mutex_struct::cond_notified, rb_mutex_struct::cond_waiting, rb_mutex_struct::lock, RUBY_VM_INTERRUPTED, rb_mutex_struct::th, and rb_thread_struct::transition_for_lock.

Referenced by rb_mutex_lock().

static void lock_interrupt | ( | void * | ptr | ) | `[static]`

Definition at line 3178 of file thread.c.

References rb_mutex_struct::cond, rb_mutex_struct::cond_notified, rb_mutex_struct::cond_waiting, and rb_mutex_struct::lock.

Referenced by rb_mutex_lock().

static VALUE mutex_alloc | ( | VALUE | klass | ) | `[static]`

Definition at line 3060 of file thread.c.

References rb_mutex_struct::cond, rb_mutex_struct::lock, and TypedData_Make_Struct.

Referenced by barrier_alloc(), Init_Thread(), and rb_mutex_new().

static void mutex_free | ( | void * | ptr | ) | `[static]`

Definition at line 3033 of file thread.c.

References rb_mutex_struct::cond, err, rb_mutex_struct::lock, mutex_unlock(), rb_bug(), ruby_xfree(), and rb_mutex_struct::th.

static VALUE mutex_initialize | ( | VALUE | self | ) | `[static]`

Definition at line 3078 of file thread.c.

Referenced by Init_Thread().

static void mutex_locked | ( | rb_thread_t * | th,
|  | VALUE | self
| ) |  | `[static]`

Definition at line 3104 of file thread.c.

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

Referenced by rb_mutex_lock(), and rb_mutex_trylock().

static size_t mutex_memsize | ( | const void * | ptr | ) | `[static]`

Definition at line 3049 of file thread.c.

static VALUE mutex_sleep | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  | `[static]`

Definition at line 3393 of file thread.c.

References rb_mutex_sleep(), and rb_scan_args().

Referenced by Init_Thread().

static const char * mutex_unlock | ( | mutex_t * | mutex,
|  | rb_thread_t volatile * | th
| ) |  | `[static]`

Definition at line 3252 of file thread.c.

References rb_mutex_struct::cond, rb_mutex_struct::cond_notified, rb_mutex_struct::cond_waiting, err, rb_thread_struct::keeping_mutexes, rb_mutex_struct::lock, rb_mutex_struct::next_mutex, NULL, and rb_mutex_struct::th.

Referenced by mutex_free(), rb_mutex_unlock(), and rb_mutex_unlock_all().

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

void rb_add_event_hook | ( | rb_event_hook_func_t | func,
|  | rb_event_flag_t | events,
|  | VALUE | data
| ) |  |

Definition at line 3806 of file thread.c.

References alloc_event_hook(), rb_vm_struct::event_hooks, GET_VM, rb_event_hook_struct::next, and set_threads_event_flags().

Referenced by rb_set_coverages(), and set_trace_func().

VALUE rb_barrier_destroy | ( | VALUE | self | ) |

Definition at line 3468 of file thread.c.

References DATA_PTR, GetBarrierPtr, and rb_mutex_unlock().

Referenced by load_unlock().

VALUE rb_barrier_new | ( | void |  | ) |

Definition at line 3439 of file thread.c.

References barrier_alloc(), DATA_PTR, rb_cBarrier, and rb_mutex_lock().

Referenced by load_lock().

VALUE rb_barrier_release | ( | VALUE | self | ) |

Definition at line 3462 of file thread.c.

References GetBarrierPtr, and rb_mutex_unlock().

Referenced by load_unlock().

VALUE rb_barrier_wait | ( | VALUE | self | ) |

Definition at line 3447 of file thread.c.

References DATA_PTR, GET_THREAD, GetBarrierPtr, GetMutexPtr, Qfalse, Qtrue, rb_mutex_lock(), rb_mutex_unlock(), and rb_mutex_struct::th.

Referenced by load_lock().

static void rb_check_deadlock | ( | rb_vm_t * | vm | ) | `[static]`

Definition at line 4319 of file thread.c.

References argv, check_deadlock_i(), GET_THREAD, rb_vm_struct::living_threads, rb_vm_struct::main_thread, st_table::num_entries, rb_bug(), rb_eFatal, rb_str_new2(), rb_threadptr_raise(), rb_vm_struct::sleeper, st_foreach, and vm_living_thread_num().

Referenced by rb_mutex_lock(), and sleep_forever().

void rb_clear_trace_func | ( | void |  | ) |

Definition at line 3879 of file thread.c.

References clear_trace_func_i(), GET_VM, rb_remove_event_hook(), and st_foreach.

Referenced by ruby_finalize_0(), and ruby_options().

void rb_disable_interrupt | ( | void |  | ) |

Definition at line 543 of file signal.c.

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

Definition at line 3674 of file thread.c.

References exec_recursive(), and func.

Referenced by ary_join_1(), enumerator_inspect(), range_inspect(), rb_ary_inspect(), rb_file_join(), rb_hash_inspect(), rb_io_puts(), rb_obj_inspect(), and rb_struct_inspect().

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

Definition at line 3697 of file thread.c.

References exec_recursive(), and func.

Referenced by range_hash(), rb_ary_hash(), rb_hash_hash(), and rb_struct_hash().

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

Definition at line 3685 of file thread.c.

References exec_recursive(), func, and rb_obj_id().

Referenced by hash_equal(), range_eq(), range_eql(), rb_ary_cmp(), rb_ary_eql(), rb_ary_equal(), rb_struct_eql(), and rb_struct_equal().

void rb_gc_mark_threads | ( | void |  | ) |

Definition at line 1327 of file thread.c.

Referenced by garbage_collect().

void rb_gc_save_machine_context | ( | rb_thread_t * | th | ) |

Definition at line 2644 of file thread.c.

References FLUSH_REGISTER_WINDOWS, and rb_thread_struct::machine_regs.

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

Definition at line 2636 of file thread.c.

VALUE rb_get_coverages | ( | void |  | ) |

Definition at line 4359 of file thread.c.

References GET_VM.

Referenced by clear_coverage(), coverage(), prepare_iseq_build(), rb_coverage_result(), and rb_coverage_start().

int rb_get_next_signal | ( | void |  | ) |

Definition at line 565 of file signal.c.

References ATOMIC_DEC, rb_disable_interrupt(), rb_enable_interrupt(), RUBY_NSIG, and signal_buff.

Referenced by rb_threadptr_check_signal().

static void rb_mutex_abandon_all | ( | mutex_t * | mutexes | ) | `[static]`

Definition at line 3336 of file thread.c.

References rb_mutex_struct::next_mutex, and rb_mutex_struct::th.

Referenced by terminate_atfork_i().

VALUE rb_mutex_lock | ( | VALUE | self | ) |

Definition at line 3198 of file thread.c.

References BLOCKING_REGION_CORE, GET_THREAD, GetMutexPtr, lock_func(), lock_interrupt(), rb_thread_struct::locking_mutex, mutex_locked(), Qfalse, rb_check_deadlock(), rb_eThreadError, rb_mutex_trylock(), rb_raise(), reset_unblock_function(), RUBY_VM_CHECK_INTS, set_unblock_function(), rb_vm_struct::sleeper, rb_thread_struct::status, rb_mutex_struct::th, THREAD_STOPPED_FOREVER, rb_thread_struct::transition_for_lock, rb_thread_struct::vm, and vm_living_thread_num().

Referenced by Init_Thread(), rb_barrier_new(), rb_barrier_wait(), rb_mutex_sleep(), and rb_mutex_synchronize().

VALUE rb_mutex_locked_p | ( | VALUE | self | ) |

Definition at line 3096 of file thread.c.

References GetMutexPtr, Qfalse, Qtrue, and rb_mutex_struct::th.

Referenced by Init_Thread().

VALUE rb_mutex_new | ( | void |  | ) |

Definition at line 3084 of file thread.c.

References mutex_alloc(), and rb_cMutex.

Referenced by io_binwrite().

VALUE rb_mutex_sleep | ( | VALUE | self,
|  | VALUE | timeout
| ) |  |

Definition at line 3364 of file thread.c.

References INT2FIX, NIL_P, Qnil, rb_ensure(), rb_mutex_lock(), rb_mutex_sleep_forever(), rb_mutex_unlock(), rb_mutex_wait_for(), rb_time_interval(), and time_t.

Referenced by mutex_sleep().

static VALUE rb_mutex_sleep_forever | ( | VALUE | time | ) | `[static]`

Definition at line 3349 of file thread.c.

References Qnil, and rb_thread_sleep_deadly().

Referenced by rb_mutex_sleep().

VALUE rb_mutex_synchronize | ( | VALUE | mutex,
|  | VALUE(*)(VALUE arg) | func,
|  | VALUE | arg
| ) |  |

Definition at line 3410 of file thread.c.

References func, rb_ensure(), rb_mutex_lock(), and rb_mutex_unlock().

Referenced by fptr_finalize(), io_binwrite(), and io_flush_buffer().

VALUE rb_mutex_trylock | ( | VALUE | self | ) |

Definition at line 3123 of file thread.c.

References GET_THREAD, GetMutexPtr, rb_mutex_struct::lock, mutex_locked(), Qfalse, Qtrue, and rb_mutex_struct::th.

Referenced by Init_Thread(), and rb_mutex_lock().

VALUE rb_mutex_unlock | ( | VALUE | self | ) |

Definition at line 3307 of file thread.c.

References err, GET_THREAD, GetMutexPtr, mutex_unlock(), rb_eThreadError, and rb_raise().

Referenced by Init_Thread(), rb_barrier_destroy(), rb_barrier_release(), rb_barrier_wait(), rb_mutex_sleep(), and rb_mutex_synchronize().

static void rb_mutex_unlock_all | ( | mutex_t * | mutex,
|  | rb_thread_t * | th
| ) |  | `[static]`

Definition at line 3320 of file thread.c.

References err, mutex_unlock(), rb_mutex_struct::next_mutex, and rb_bug().

Referenced by rb_thread_terminate_all(), and thread_unlock_all_locking_mutexes().

static VALUE rb_mutex_wait_for | ( | VALUE | time | ) | `[static]`

Definition at line 3356 of file thread.c.

References Qnil, and rb_thread_wait_for().

Referenced by rb_mutex_sleep().

int rb_remove_event_hook | ( | rb_event_hook_func_t | func | ) |

Definition at line 3856 of file thread.c.

References rb_vm_struct::event_hooks, GET_VM, NULL, remove_event_hook(), and set_threads_event_flags().

Referenced by rb_clear_trace_func(), rb_reset_coverages(), and set_trace_func().

void rb_reset_coverages | ( | void |  | ) |

Definition at line 4372 of file thread.c.

References GET_VM, Qfalse, rb_remove_event_hook(), and update_coverage().

Referenced by rb_coverage_result().

void rb_set_coverages | ( | VALUE | coverages | ) |

Definition at line 4365 of file thread.c.

References GET_VM, Qnil, rb_add_event_hook(), RUBY_EVENT_COVERAGE, and update_coverage().

Referenced by rb_coverage_start().

int rb_signal_buff_size | ( | void |  | ) |

Definition at line 525 of file signal.c.

References signal_buff.

Referenced by rb_threadptr_execute_interrupts_rec().

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

Definition at line 646 of file signal.c.

References rb_vm_struct::cmd, GET_VM, Qundef, rb_interrupt(), rb_threadptr_signal_exit(), rb_threadptr_signal_raise(), rb_vm_struct::safe, SIGINT, signal_exec(), and rb_vm_struct::trap_list.

Referenced by rb_threadptr_execute_interrupts_rec().

static VALUE rb_thread_abort_exc | ( | VALUE | thread | ) | `[static]`

Definition at line 1773 of file thread.c.

References rb_thread_struct::abort_on_exception, GetThreadPtr, Qfalse, and Qtrue.

Referenced by Init_Thread().

static VALUE rb_thread_abort_exc_set | ( | VALUE | thread,
|  | VALUE | val
| ) |  | `[static]`

Definition at line 1791 of file thread.c.

References rb_thread_struct::abort_on_exception, GetThreadPtr, rb_secure(), and RTEST.

Referenced by Init_Thread().

void rb_thread_add_event_hook | ( | VALUE | thval,
|  | rb_event_hook_func_t | func,
|  | rb_event_flag_t | events,
|  | VALUE | data
| ) |  |

Definition at line 3746 of file thread.c.

References rb_threadptr_add_event_hook(), and thval2thread_t().

static VALUE rb_thread_alive_p | ( | VALUE | thread | ) | `[static]`

Definition at line 1903 of file thread.c.

References GetThreadPtr, Qfalse, Qtrue, and rb_threadptr_dead().

Referenced by call_queue_handler(), eval_queue_handler(), Init_Thread(), invoke_queue_handler(), lib_eventloop_ensure(), and lib_thread_callback().

int rb_thread_alone | ( | void |  | ) |

Definition at line 2109 of file thread.c.

References GET_THREAD, thread_debug, and vm_living_thread_num().

Referenced by io_writable_length(), ip_rb_threadTkWaitCommand(), ip_rb_threadUpdateCommand(), ip_rb_threadVwaitCommand(), ip_rbTkWaitCommand(), ip_rbVwaitCommand(), lib_eventloop_core(), rb_thread_polling(), rb_thread_schedule_rec(), rb_thread_stop(), rb_thread_terminate_all(), rb_thread_wait_fd_rw(), and rb_waitpid().

static VALUE rb_thread_aref | ( | VALUE | thread,
|  | VALUE | id
| ) |  | `[static]`

Definition at line 2023 of file thread.c.

References rb_thread_local_aref(), and rb_to_id().

Referenced by Init_Thread().

static VALUE rb_thread_aset | ( | VALUE | self,
|  | VALUE | id,
|  | VALUE | val
| ) |  | `[static]`

Definition at line 2060 of file thread.c.

References rb_thread_local_aset(), and rb_to_id().

Referenced by Init_Thread().

void rb_thread_atfork | ( | void |  | ) |

Definition at line 2779 of file thread.c.

References GET_THREAD, rb_reset_random_seed(), rb_thread_atfork_internal(), and terminate_atfork_i().

void rb_thread_atfork_before_exec | ( | void |  | ) |

Definition at line 2800 of file thread.c.

References rb_thread_atfork_internal(), and terminate_atfork_before_exec_i().

Referenced by chfunc().

static void rb_thread_atfork_internal | ( | int(*)(st_data_t, st_data_t, st_data_t) | atfork | ) | `[static]`

Definition at line 2746 of file thread.c.

References clear_coverage(), GET_THREAD, rb_vm_struct::global_vm_lock, rb_vm_struct::living_threads, rb_vm_struct::main_thread, rb_thread_struct::self, rb_vm_struct::sleeper, st_clear(), st_foreach, st_insert, and rb_thread_struct::vm.

Referenced by rb_thread_atfork(), and rb_thread_atfork_before_exec().

VALUE rb_thread_backtrace | ( | VALUE | thval | ) |

Definition at line 1624 of file vm_eval.c.

References GetThreadPtr, Qnil, rb_thread_struct::status, THREAD_KILLED, THREAD_RUNNABLE, THREAD_STOPPED, THREAD_STOPPED_FOREVER, THREAD_TO_KILL, and vm_backtrace().

Referenced by rb_thread_backtrace_m().

static VALUE rb_thread_backtrace_m | ( | VALUE | thval | ) | `[static]`

Definition at line 4136 of file thread.c.

References rb_thread_backtrace().

Referenced by Init_Thread().

VALUE rb_thread_blocking_region | ( | rb_blocking_function_t * | func,
|  | void * | data1,
|  | rb_unblock_function_t * | ubf,
|  | void * | data2
| ) |  |

Definition at line 1104 of file thread.c.

References BLOCKING_REGION, errno, func, GET_THREAD, RUBY_UBF_IO, and RUBY_UBF_PROCESS.

Referenced by bigdivrem(), copy_stream_body(), curses_getch(), curses_getstr(), io_flush_buffer_async(), rb_file_flock(), rb_read_internal(), rb_sysopen_internal(), rb_thread_call_without_gvl(), rb_waitpid(), rb_write_internal(), window_getch(), and window_getstr().

struct rb_blocking_region_buffer* rb_thread_blocking_region_begin | ( | void |  | ) | `[read]`

Definition at line 1048 of file thread.c.

References ALLOC, blocking_region_begin, and GET_THREAD.

void rb_thread_blocking_region_end | ( | struct rb_blocking_region_buffer * | region | ) |

Definition at line 1057 of file thread.c.

References blocking_region_end(), errno, GET_THREAD, RUBY_VM_CHECK_INTS, and xfree().

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

Definition at line 1169 of file thread.c.

References rb_unblock_callback::arg, blocking_region_begin, rb_thread_struct::blocking_region_buffer, blocking_region_end(), rb_unblock_callback::func, if(), rb_bug(), and rb_thread_struct::unblock.

Referenced by garbage_collect_with_gvl(), negative_size_allocation_error(), and ruby_memerror().

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

Definition at line 1129 of file thread.c.

References rb_thread_blocking_region().

void rb_thread_check_ints | ( | void |  | ) |

Definition at line 966 of file thread.c.

References RUBY_VM_CHECK_INTS.

Referenced by bigmul1_normal(), collect_all(), and trap_check().

int rb_thread_check_trap_pending | ( | void |  | ) |

Definition at line 976 of file thread.c.

References GET_THREAD.

Referenced by ip_rbTkWaitCommand(), ip_rbUpdateCommand(), ip_rbVwaitCommand(), and trap_check().

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

Definition at line 627 of file thread.c.

References rb_cThread, rb_thread_alloc(), and thread_create_core().

Referenced by lib_thread_callback(), lib_watchdog_core(), and rb_detach_process().

VALUE rb_thread_current | ( | void |  | ) |

Definition at line 1671 of file thread.c.

References GET_THREAD.

Referenced by call_queue_handler(), chdir_yield(), copy_stream_body(), dir_s_chdir(), eval_queue_handler(), eventloop_sleep(), invoke_queue_handler(), ip_eval(), ip_invoke_real(), ip_invoke_with_position(), ip_rb_threadTkWaitCommand(), ip_rb_threadUpdateCommand(), ip_rb_threadVwaitCommand(), ip_rbTkWaitCommand(), ip_rbVwaitCommand(), lib_eventloop_ensure(), lib_eventloop_launcher(), lib_evloop_thread_p(), lib_watchdog_core(), rb_dl_get_last_error(), rb_dl_set_last_error(), recursive_list_access(), recursive_pop(), thread_s_current(), and tk_funcall().

static VALUE rb_thread_exit | ( | void |  | ) | `[static]`

Definition at line 1526 of file thread.c.

References GET_THREAD, and rb_thread_kill().

Referenced by Init_Thread().

void rb_thread_fd_close | ( | int | fd | ) |

Definition at line 1419 of file thread.c.

Referenced by io_reopen(), and rb_io_close().

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 2600 of file thread.c.

References do_select(), NULL, rb_fd_ptr, rb_fd_resize, rb_thread_sleep_forever(), and rb_thread_wait_for().

Referenced by select_internal().

int rb_thread_fd_writable | ( | int | fd | ) |

Definition at line 2575 of file thread.c.

References rb_thread_wait_fd_rw(), and TRUE.

Referenced by io_binwrite(), io_fflush(), rb_io_syswrite(), rb_io_wait_writable(), rsock_bsock_send(), and udp_send().

VALUE rb_thread_group | ( | VALUE | thread | ) |

Definition at line 1813 of file thread.c.

References GetThreadPtr, Qnil, and rb_thread_struct::thgroup.

Referenced by Init_Thread().

static VALUE rb_thread_inspect | ( | VALUE | thread | ) | `[static]`

Definition at line 1967 of file thread.c.

References GetThreadPtr, OBJ_INFECT, rb_obj_classname(), rb_sprintf(), rb_thread_struct::status, and thread_status_name().

Referenced by Init_Thread().

int rb_thread_interrupted | ( | VALUE | thval | ) |

Definition at line 983 of file thread.c.

References GetThreadPtr, and RUBY_VM_INTERRUPTED.

Referenced by nogvl_copy_stream_read_write().

static VALUE rb_thread_key_p | ( | VALUE | self,
|  | VALUE | key
| ) |  | `[static]`

Definition at line 2079 of file thread.c.

References GetThreadPtr, rb_thread_struct::local_storage, Qfalse, Qtrue, rb_to_id(), and st_lookup.

Referenced by Init_Thread().

static VALUE rb_thread_keys | ( | VALUE | self | ) | `[static]`

Definition at line 2134 of file thread.c.

References GetThreadPtr, rb_thread_struct::local_storage, rb_ary_new(), st_foreach, and thread_keys_i().

Referenced by Init_Thread().

VALUE rb_thread_kill | ( | VALUE | thread | ) |

Definition at line 1468 of file thread.c.

References eKillSignal, EXIT_SUCCESS, GET_THREAD, GetThreadPtr, rb_vm_struct::main_thread, rb_exit(), rb_secure(), rb_threadptr_interrupt(), rb_thread_struct::safe_level, rb_thread_struct::status, thread_debug, rb_thread_struct::thread_id, THREAD_KILLED, THREAD_TO_KILL, and rb_thread_struct::vm.

Referenced by Init_Thread(), rb_thread_exit(), and rb_thread_s_kill().

VALUE rb_thread_list | ( | void |  | ) |

Definition at line 1663 of file thread.c.

References GET_THREAD, rb_ary_new(), st_foreach, and thread_list_i().

Referenced by Init_Thread().

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

Definition at line 1983 of file thread.c.

References GET_THREAD, GetThreadPtr, rb_thread_struct::local_storage, Qnil, rb_eSecurityError, rb_raise(), rb_safe_level, and st_lookup.

Referenced by detach_process_pid(), rb_dl_get_last_error(), rb_thread_aref(), and recursive_list_access().

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

Definition at line 2029 of file thread.c.

References GET_THREAD, GetThreadPtr, rb_thread_struct::local_storage, NIL_P, OBJ_FROZEN, Qnil, rb_error_frozen(), rb_eSecurityError, rb_raise(), rb_safe_level, st_delete_wrap(), st_init_numtable, and st_insert.

Referenced by rb_detach_process(), rb_dl_set_last_error(), rb_thread_aset(), and recursive_list_access().

void rb_thread_lock_destroy | ( | rb_thread_lock_t * | lock | ) |

Definition at line 261 of file thread.c.

Referenced by ruby_vm_destruct().

void rb_thread_lock_unlock | ( | rb_thread_lock_t * | lock | ) |

Definition at line 255 of file thread.c.

Referenced by ruby_vm_destruct().

VALUE rb_thread_main | ( | void |  | ) |

Definition at line 1692 of file thread.c.

References GET_THREAD.

Referenced by rb_thread_s_main().

void rb_thread_polling | ( | void |  | ) |

Definition at line 949 of file thread.c.

References GET_THREAD, rb_thread_alone(), RUBY_VM_CHECK_INTS, and sleep_for_polling().

Referenced by rb_f_kill(), and rb_file_flock().

static VALUE rb_thread_priority | ( | VALUE | thread | ) | `[static]`

Definition at line 2162 of file thread.c.

References GetThreadPtr, INT2NUM(), and rb_thread_struct::priority.

Referenced by Init_Thread().

static VALUE rb_thread_priority_set | ( | VALUE | thread,
|  | VALUE | prio
| ) |  | `[static]`

Definition at line 2197 of file thread.c.

References GetThreadPtr, INT2NUM(), NUM2INT, rb_thread_struct::priority, rb_secure(), RUBY_THREAD_PRIORITY_MAX, RUBY_THREAD_PRIORITY_MIN, and rb_thread_struct::slice.

Referenced by Init_Thread().

void rb_thread_recycle_stack_release | ( | VALUE * |  | ) |

Definition at line 1609 of file vm.c.

References RECYCLE_MAX, and ruby_xfree().

Referenced by thread_start_func_2().

int rb_thread_remove_event_hook | ( | VALUE | thval,
|  | rb_event_hook_func_t | func
| ) |  |

Definition at line 3850 of file thread.c.

References rb_threadptr_revmove_event_hook(), and thval2thread_t().

void rb_thread_reset_timer_thread | ( | void |  | ) |

Definition at line 2709 of file thread.c.

VALUE rb_thread_run | ( | VALUE | thread | ) |

Definition at line 1584 of file thread.c.

References rb_thread_schedule(), and rb_thread_wakeup().

Referenced by call_queue_handler(), eval_queue_handler(), Init_Thread(), invoke_queue_handler(), lib_eventloop_launcher(), and lib_watchdog_core().

static VALUE rb_thread_s_abort_exc | ( | void |  | ) | `[static]`

Definition at line 1724 of file thread.c.

References GET_THREAD, Qfalse, and Qtrue.

Referenced by Init_Thread().

static VALUE rb_thread_s_abort_exc_set | ( | VALUE | self,
|  | VALUE | val
| ) |  | `[static]`

Definition at line 1755 of file thread.c.

References GET_THREAD, rb_secure(), and RTEST.

Referenced by Init_Thread().

static VALUE rb_thread_s_kill | ( | VALUE | obj,
|  | VALUE | th
| ) |  | `[static]`

Definition at line 1509 of file thread.c.

References rb_thread_kill().

Referenced by Init_Thread().

static VALUE rb_thread_s_main | ( | VALUE | klass | ) | `[static]`

Definition at line 1705 of file thread.c.

References rb_thread_main().

Referenced by Init_Thread().

static VALUE rb_thread_safe_level | ( | VALUE | thread | ) | `[static]`

Definition at line 1951 of file thread.c.

References GetThreadPtr, INT2NUM(), and rb_thread_struct::safe_level.

Referenced by Init_Thread().

void rb_thread_schedule | ( | void |  | ) |

Definition at line 1026 of file thread.c.

References rb_thread_schedule_rec().

Referenced by call_queue_handler(), eval_queue_handler(), invoke_queue_handler(), lib_eventloop_core(), lib_thread_callback(), proc_waitall(), rb_thread_run(), rb_thread_terminate_all(), rb_threadptr_raise(), rb_waitpid(), thread_s_pass(), and zstream_run().

static void rb_thread_schedule_rec | ( | int | sched_depth | ) | `[static]`

Definition at line 1001 of file thread.c.

References GET_THREAD, rb_vm_struct::global_vm_lock, RB_GC_SAVE_MACHINE_CONTEXT, rb_thread_alone(), rb_thread_set_current, rb_threadptr_execute_interrupts_rec(), thread_debug, UNLIKELY, and rb_thread_struct::vm.

Referenced by rb_thread_schedule(), and rb_threadptr_execute_interrupts_rec().

int rb_thread_select | ( | int | max,
|  | fd_set * | read,
|  | fd_set * | write,
|  | fd_set * | except,
|  | struct timeval * | timeout
| ) |  |

Definition at line 2582 of file thread.c.

References do_select(), rb_thread_sleep_forever(), and rb_thread_wait_for().

Referenced by io_wait(), rb_io_wait_readable(), rb_io_wait_writable(), and wait_connectable0().

void rb_thread_sleep | ( | int | sec | ) |

Definition at line 993 of file thread.c.

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

Referenced by pipe_open().

static void rb_thread_sleep_deadly | ( | void |  | ) | `[static]`

Definition at line 903 of file thread.c.

References GET_THREAD, sleep_forever(), and thread_debug.

Referenced by rb_mutex_sleep_forever(), and rb_thread_stop().

void rb_thread_sleep_forever | ( | void |  | ) |

Definition at line 896 of file thread.c.

References GET_THREAD, sleep_forever(), and thread_debug.

Referenced by lib_eventloop_core(), rb_f_sleep(), rb_thread_fd_select(), and rb_thread_select().

void rb_thread_start_timer_thread | ( | void |  | ) |

Definition at line 2715 of file thread.c.

References system_working.

static VALUE rb_thread_status | ( | VALUE | thread | ) | `[static]`

Definition at line 1874 of file thread.c.

References rb_thread_struct::errinfo, FIXNUM_P, GetThreadPtr, NIL_P, Qfalse, Qnil, rb_str_new2(), rb_threadptr_dead(), rb_thread_struct::status, and thread_status_name().

VALUE rb_thread_stop | ( | void |  | ) |

Definition at line 1611 of file thread.c.

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

Referenced by Init_Thread().

static VALUE rb_thread_stop_p | ( | VALUE | thread | ) | `[static]`

Definition at line 1926 of file thread.c.

References GetThreadPtr, Qfalse, Qtrue, rb_threadptr_dead(), rb_thread_struct::status, THREAD_STOPPED, and THREAD_STOPPED_FOREVER.

Referenced by Init_Thread().

void rb_thread_stop_timer_thread | ( | void |  | ) |

Definition at line 2701 of file thread.c.

Referenced by rb_thread_terminate_all(), and ruby_cleanup().

void rb_thread_terminate_all | ( | void |  | ) |

Definition at line 340 of file thread.c.

References EXEC_TAG, GET_THREAD, rb_thread_struct::keeping_mutexes, rb_vm_struct::living_threads, rb_vm_struct::main_thread, POP_TAG, PUSH_TAG, rb_bug(), rb_mutex_unlock_all(), rb_thread_alone(), rb_thread_schedule(), rb_thread_stop_timer_thread(), st_foreach, terminate_i(), rb_mutex_struct::th, thread_debug, and rb_thread_struct::vm.

Referenced by ruby_cleanup().

void rb_thread_wait_fd | ( | int | fd | ) |

Definition at line 2569 of file thread.c.

References rb_thread_wait_fd_rw().

Referenced by copy_stream_fallback_body(), io_fread(), ossl_ssl_read_internal(), rb_io_read_check(), rb_io_sysread(), rb_io_wait_readable(), rb_read_check(), rsock_s_accept(), and rsock_s_recvfrom().

static void rb_thread_wait_fd_rw | ( | int | fd,
|  | int | read
| ) |  | `[static]`

Definition at line 2537 of file thread.c.

References do_select(), FD_SET, rb_eIOError, rb_fd_init, rb_fd_ptr, rb_fd_term, rb_raise(), rb_sys_fail(), rb_thread_alone(), result, and thread_debug.

Referenced by rb_thread_fd_writable(), and rb_thread_wait_fd().

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

Definition at line 942 of file thread.c.

References GET_THREAD, and sleep_timeval().

Referenced by eventloop_sleep(), ip_eval(), ip_invoke_with_position(), ip_rb_threadTkWaitCommand(), ip_rb_threadUpdateCommand(), ip_rb_threadVwaitCommand(), lib_watchdog_core(), rb_f_sleep(), rb_mutex_wait_for(), rb_thread_fd_select(), rb_thread_select(), rb_thread_sleep(), rsock_connect(), and tk_funcall().

VALUE rb_thread_wakeup | ( | VALUE | thread | ) |

Definition at line 1548 of file thread.c.

References GetThreadPtr, rb_eThreadError, rb_raise(), rb_threadptr_ready(), rb_thread_struct::status, THREAD_KILLED, THREAD_RUNNABLE, and THREAD_TO_KILL.

Referenced by call_queue_handler(), eval_queue_handler(), Init_Thread(), invoke_queue_handler(), lib_eventloop_ensure(), rb_thread_run(), rb_threadUpdateProc(), rb_threadVwaitProc(), rb_threadWaitVisibilityProc(), and rb_threadWaitWindowProc().

static void rb_threadptr_add_event_hook | ( | rb_thread_t * | th,
|  | rb_event_hook_func_t | func,
|  | rb_event_flag_t | events,
|  | VALUE | data
| ) |  | `[static]`

Definition at line 3728 of file thread.c.

References alloc_event_hook(), rb_thread_struct::event_hooks, rb_event_hook_struct::next, and thread_reset_event_flags().

Referenced by rb_thread_add_event_hook(), and thread_add_trace_func().

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

Definition at line 2660 of file thread.c.

References rb_thread_struct::exec_signal, rb_get_next_signal(), rb_threadptr_interrupt(), rb_thread_struct::status, thread_debug, THREAD_KILLED, THREAD_RUNNABLE, and thread_status_name().

Referenced by ruby_cleanup(), and timer_thread_function().

static int rb_threadptr_dead | ( | rb_thread_t * | th | ) | `[static]`

Definition at line 1845 of file thread.c.

References rb_thread_struct::status, and THREAD_KILLED.

Referenced by rb_thread_alive_p(), rb_thread_status(), rb_thread_stop_p(), and rb_threadptr_raise().

void rb_threadptr_exec_event_hooks | ( | rb_thread_t * | th,
|  | rb_event_flag_t | flag,
|  | VALUE | self,
|  | ID | id,
|  | VALUE | klass
| ) |  |

Definition at line 3785 of file thread.c.

References rb_thread_struct::errinfo, rb_thread_struct::event_flags, rb_vm_struct::event_hooks, rb_thread_struct::event_hooks, exec_event_hooks(), NULL, rb_mRubyVMFrozenCore, RUBY_EVENT_VM, and rb_thread_struct::vm.

void rb_threadptr_execute_interrupts | ( | rb_thread_t * | th | ) |

Definition at line 1321 of file thread.c.

References rb_threadptr_execute_interrupts_rec().

static void rb_threadptr_execute_interrupts_rec | ( | rb_thread_t * | th,
|  | int | sched_depth
| ) |  | `[static]`

Definition at line 1255 of file thread.c.

References rb_thread_struct::cfp, eKillSignal, err, rb_thread_struct::errinfo, eTerminateSignal, EXEC_EVENT_HOOK, rb_thread_struct::exec_signal, GET_VM, INT2FIX, rb_thread_struct::interrupt_flag, rb_thread_struct::priority, rb_thread_struct::raised_flag, rb_exc_raise(), rb_gc_finalize_deferred(), rb_signal_buff_size(), rb_signal_exec(), rb_thread_schedule_rec(), RUBY_EVENT_SWITCH, rb_control_frame_t::self, rb_thread_struct::slice, rb_thread_struct::status, TAG_FATAL, TH_JUMP_TAG, thread_debug, THREAD_RUNNABLE, and rb_thread_struct::thrown_errinfo.

Referenced by rb_thread_schedule_rec(), and rb_threadptr_execute_interrupts().

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

Definition at line 294 of file thread.c.

References rb_unblock_callback::arg, rb_unblock_callback::func, rb_thread_struct::interrupt_lock, RUBY_VM_SET_INTERRUPT, and rb_thread_struct::unblock.

Referenced by rb_thread_kill(), rb_threadptr_check_signal(), rb_threadptr_ready(), ruby_cleanup(), terminate_i(), and thread_start_func_2().

static VALUE rb_threadptr_raise | ( | rb_thread_t * | th,
|  | int | argc,
|  | VALUE * | argv
| ) |  | `[static]`

Definition at line 1341 of file thread.c.

References Qnil, rb_thread_struct::raised_flag, rb_make_exception(), rb_thread_schedule(), rb_threadptr_dead(), rb_threadptr_ready(), and rb_thread_struct::thrown_errinfo.

Referenced by rb_check_deadlock(), rb_threadptr_signal_exit(), rb_threadptr_signal_raise(), thread_raise_m(), and thread_start_func_2().

static void rb_threadptr_ready | ( | rb_thread_t * | th | ) | `[static]`

Definition at line 1335 of file thread.c.

References rb_threadptr_interrupt().

Referenced by rb_thread_wakeup(), and rb_threadptr_raise().

int rb_threadptr_reset_raised | ( | rb_thread_t * | th | ) |

Definition at line 1409 of file thread.c.

References RAISED_EXCEPTION, and rb_thread_struct::raised_flag.

Referenced by error_handle(), ruby_suppress_tracing(), and setup_exception().

static int rb_threadptr_revmove_event_hook | ( | rb_thread_t * | th,
|  | rb_event_hook_func_t | func
| ) |  | `[static]`

Definition at line 3842 of file thread.c.

References rb_thread_struct::event_hooks, remove_event_hook(), and thread_reset_event_flags().

Referenced by clear_trace_func_i(), rb_thread_remove_event_hook(), and thread_set_trace_func_m().

int rb_threadptr_set_raised | ( | rb_thread_t * | th | ) |

Definition at line 1399 of file thread.c.

References RAISED_EXCEPTION, and rb_thread_struct::raised_flag.

Referenced by error_handle(), ruby_suppress_tracing(), and setup_exception().

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

Definition at line 1372 of file thread.c.

References argv, rb_vm_struct::main_thread, rb_eSystemExit, rb_str_new2(), rb_threadptr_raise(), and rb_thread_struct::vm.

Referenced by rb_signal_exec().

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

Definition at line 1362 of file thread.c.

References argv, INT2FIX, rb_vm_struct::main_thread, rb_eSignal, rb_threadptr_raise(), and rb_thread_struct::vm.

Referenced by rb_signal_exec().

struct timeval rb_time_interval | ( | VALUE |  | ) | `[read]`

Definition at line 2371 of file time.c.

References time_timeval(), and TRUE.

struct timeval rb_time_timeval | ( | VALUE |  | ) | `[read]`

Definition at line 2377 of file time.c.

References FALSE, GetTimeval, IsTimeval, time_timeval(), timew2timespec(), timespec::tv_nsec, timespec::tv_sec, timeval::tv_sec, timeval::tv_usec, TYPEOF_TIMEVAL_TV_SEC, and TYPEOF_TIMEVAL_TV_USEC.

static VALUE recursive_check | ( | VALUE | list,
|  | VALUE | obj_id,
|  | VALUE | paired_obj_id
| ) |  | `[static]`

Definition at line 3514 of file thread.c.

References NIL_P, Qfalse, Qtrue, Qundef, rb_hash_lookup, rb_hash_lookup2(), T_HASH, and TYPE.

Referenced by exec_recursive().

static VALUE recursive_list_access | ( | void |  | ) | `[static]`

Definition at line 3485 of file thread.c.

References hash(), ID2SYM, list, NIL_P, OBJ_UNTRUST, Qnil, rb_frame_this_func(), rb_hash_aref(), rb_hash_aset(), rb_hash_new(), rb_thread_current(), rb_thread_local_aref(), rb_thread_local_aset(), T_HASH, and TYPE.

Referenced by exec_recursive().

static void recursive_pop | ( | VALUE | list,
|  | VALUE | obj,
|  | VALUE | paired_obj
| ) |  | `[static]`

Definition at line 3573 of file thread.c.

References ID2SYM, Qundef, rb_eTypeError, rb_frame_this_func(), rb_hash_delete(), rb_hash_lookup2(), rb_inspect(), rb_raise(), rb_thread_current(), RHASH_EMPTY_P, StringValuePtr, T_HASH, and TYPE.

Referenced by exec_recursive(), and exec_recursive_i().

static void recursive_push | ( | VALUE | list,
|  | VALUE | obj,
|  | VALUE | paired_obj
| ) |  | `[static]`

Definition at line 3542 of file thread.c.

References OBJ_UNTRUST, Qtrue, Qundef, rb_hash_aset(), rb_hash_lookup2(), rb_hash_new(), T_HASH, and TYPE.

Referenced by exec_recursive(), and exec_recursive_i().

static int remove_event_hook | ( | rb_event_hook_t ** | root,
|  | rb_event_hook_func_t | func
| ) |  | `[static]`

Definition at line 3818 of file thread.c.

References rb_event_hook_struct::next, NULL, and xfree().

Referenced by rb_remove_event_hook(), and rb_threadptr_revmove_event_hook().

static VALUE remove_from_join_list | ( | VALUE | arg | ) | `[static]`

Definition at line 643 of file thread.c.

References rb_thread_struct::join_list_head, rb_thread_struct::join_list_next, Qnil, rb_thread_struct::status, join_arg::target, THREAD_KILLED, and join_arg::waiting.

Referenced by thread_join().

static void reset_unblock_function | ( | rb_thread_t * | th,
|  | const struct rb_unblock_callback * | old
| ) |  | `[static]`

Definition at line 286 of file thread.c.

References rb_thread_struct::interrupt_lock, and rb_thread_struct::unblock.

Referenced by blocking_region_end(), and rb_mutex_lock().

void ruby_error_print | ( | void |  | ) |

Definition at line 189 of file eval_error.c.

References error_print().

Referenced by rb_f_abort().

int ruby_native_thread_p | ( | void |  | ) |

Definition at line 4264 of file thread.c.

VALUE ruby_suppress_tracing | ( | VALUE(*)(VALUE, int) | func,
|  | VALUE | arg,
|  | int | always
| ) |  |

Definition at line 4088 of file thread.c.

References EXEC_TAG, GET_THREAD, JUMP_TAG, POP_TAG, PUSH_TAG, Qnil, rb_threadptr_reset_raised(), rb_threadptr_set_raised(), result, rb_thread_struct::state, and rb_thread_struct::tracing.

Referenced by call_trace_func(), and yycompile().

int ruby_thread_has_gvl_p | ( | void |  | ) |

Definition at line 1211 of file thread.c.

References rb_thread_struct::blocking_region_buffer.

Referenced by garbage_collect_with_gvl(), negative_size_allocation_error(), and ruby_memerror().

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

Definition at line 406 of file thread.c.

Referenced by Init_BareVM().

void ruby_thread_stack_overflow | ( | rb_thread_t * | th | ) |

Definition at line 1386 of file thread.c.

References rb_thread_struct::errinfo, rb_thread_struct::raised_flag, rb_exc_raise(), sysstack_error, TAG_RAISE, and TH_JUMP_TAG.

static void set_threads_event_flags | ( | int | flag | ) | `[static]`

Definition at line 3769 of file thread.c.

References GET_VM, set_threads_event_flags_i(), and st_foreach.

Referenced by rb_add_event_hook(), and rb_remove_event_hook().

static int set_threads_event_flags_i | ( | st_data_t | key,
|  | st_data_t | val,
|  | st_data_t | flag
| ) |  | `[static]`

Definition at line 3753 of file thread.c.

References rb_thread_struct::event_flags, GetThreadPtr, RUBY_EVENT_VM, and ST_CONTINUE.

Referenced by set_threads_event_flags().

static VALUE set_trace_func | ( | VALUE | obj,
|  | VALUE | trace
| ) |  | `[static]`

Definition at line 3931 of file thread.c.

References call_trace_func(), NIL_P, Qnil, rb_add_event_hook(), rb_eTypeError, rb_obj_is_proc(), rb_raise(), rb_remove_event_hook(), and RUBY_EVENT_ALL.

Referenced by Init_Thread().

static void set_unblock_function | ( | rb_thread_t * | th,
|  | rb_unblock_function_t * | func,
|  | void * | arg,
|  | struct rb_unblock_callback * | old
| ) |  | `[static]`

Definition at line 267 of file thread.c.

References rb_unblock_callback::arg, func, rb_unblock_callback::func, rb_thread_struct::interrupt_flag, rb_thread_struct::interrupt_lock, RUBY_VM_CHECK_INTS, and rb_thread_struct::unblock.

Referenced by rb_mutex_lock().

static void sleep_for_polling | ( | rb_thread_t * | th | ) | `[static]`

Definition at line 933 of file thread.c.

References sleep_timeval(), timeval::tv_sec, and timeval::tv_usec.

Referenced by rb_thread_polling().

static void sleep_forever | ( | rb_thread_t * | th,
|  | int | nodeadlock
| ) |  | `[static]`

Definition at line 828 of file thread.c.

References rb_check_deadlock(), RUBY_VM_CHECK_INTS, rb_vm_struct::sleeper, rb_thread_struct::status, THREAD_STOPPED, THREAD_STOPPED_FOREVER, and rb_thread_struct::vm.

Referenced by rb_thread_sleep_deadly(), rb_thread_sleep_forever(), and thread_join_sleep().

static void sleep_timeval | ( | rb_thread_t * | th,
|  | struct timeval | time
| ) |  | `[static]`

Definition at line 864 of file thread.c.

References getclockofday(), RUBY_VM_CHECK_INTS, rb_thread_struct::status, thread_debug, THREAD_STOPPED, timeval::tv_sec, and timeval::tv_usec.

Referenced by rb_thread_wait_for(), sleep_for_polling(), and sleep_wait_for_interrupt().

static void sleep_wait_for_interrupt | ( | rb_thread_t * | th,
|  | double | sleepsec
| ) |  | `[static]`

Definition at line 927 of file thread.c.

References double2timeval(), and sleep_timeval().

Referenced by thread_join_sleep().

static void st_delete_wrap | ( | st_table * | table,
|  | st_data_t | key
| ) |  | `[inline, static]`

Definition at line 82 of file thread.c.

References st_delete.

Referenced by rb_thread_local_aset(), thread_create_core(), and thread_start_func_2().

static int terminate_atfork_before_exec_i | ( | st_data_t | key,
|  | st_data_t | val,
|  | st_data_t | current_th
| ) |  | `[static]`

Definition at line 2787 of file thread.c.

References GetThreadPtr, ST_CONTINUE, and thread_cleanup_func_before_exec().

Referenced by rb_thread_atfork_before_exec().

static int terminate_atfork_i | ( | st_data_t | key,
|  | st_data_t | val,
|  | st_data_t | current_th
| ) |  | `[static]`

Definition at line 2762 of file thread.c.

References GetThreadPtr, rb_thread_struct::keeping_mutexes, NULL, rb_mutex_abandon_all(), ST_CONTINUE, and thread_cleanup_func().

Referenced by rb_thread_atfork().

static int terminate_i | ( | st_data_t | key,
|  | st_data_t | val,
|  | rb_thread_t * | main_thread
| ) |  | `[static]`

Definition at line 309 of file thread.c.

References eTerminateSignal, GetThreadPtr, rb_threadptr_interrupt(), ST_CONTINUE, thread_debug, and THREAD_TO_KILL.

Referenced by rb_thread_terminate_all().

static VALUE thgroup_add | ( | VALUE | group,
|  | VALUE | thread
| ) |  | `[static]`

Definition at line 2966 of file thread.c.

References thgroup::enclosed, GetThreadPtr, thgroup::group, OBJ_FROZEN, Qnil, rb_eThreadError, rb_raise(), rb_secure(), rb_thread_struct::thgroup, thgroup_data_type, and TypedData_Get_Struct.

Referenced by Init_Thread().

static VALUE thgroup_enclose | ( | VALUE | group | ) | `[static]`

Definition at line 2908 of file thread.c.

References thgroup::enclosed, thgroup::group, thgroup_data_type, and TypedData_Get_Struct.

Referenced by Init_Thread().

static VALUE thgroup_enclosed_p | ( | VALUE | group | ) | `[static]`

Definition at line 2928 of file thread.c.

References thgroup::enclosed, Qfalse, Qtrue, thgroup_data_type, and TypedData_Get_Struct.

Referenced by Init_Thread().

static VALUE thgroup_list | ( | VALUE | group | ) | `[static]`

Definition at line 2877 of file thread.c.

References thgroup_list_params::ary, GET_THREAD, thgroup_list_params::group, rb_ary_new(), st_foreach, and thgroup_list_i().

Referenced by Init_Thread().

static int thgroup_list_i | ( | st_data_t | key,
|  | st_data_t | val,
|  | st_data_t | data
| ) |  | `[static]`

Definition at line 2852 of file thread.c.

References GetThreadPtr, thgroup_list_params::group, rb_ary_push(), ST_CONTINUE, and rb_thread_struct::thgroup.

Referenced by thgroup_list().

static size_t thgroup_memsize | ( | const void * | ptr | ) | `[static]`

Definition at line 2811 of file thread.c.

static VALUE thgroup_s_alloc | ( | VALUE | klass | ) | `[static]`

Definition at line 2834 of file thread.c.

References thgroup::enclosed, thgroup::group, thgroup_data_type, and TypedData_Make_Struct.

Referenced by Init_Thread().

static void thread_add_trace_func | ( | rb_thread_t * | th,
|  | VALUE | trace
| ) |  | `[static]`

Definition at line 3948 of file thread.c.

References call_trace_func(), rb_eTypeError, rb_obj_is_proc(), rb_raise(), rb_threadptr_add_event_hook(), and RUBY_EVENT_ALL.

Referenced by thread_add_trace_func_m(), and thread_set_trace_func_m().

static VALUE thread_add_trace_func_m | ( | VALUE | obj,
|  | VALUE | trace
| ) |  | `[static]`

Definition at line 3966 of file thread.c.

References GetThreadPtr, and thread_add_trace_func().

Referenced by Init_Thread().

static void thread_cleanup_func | ( | void * | th_ptr | ) | `[static]`

Definition at line 392 of file thread.c.

References rb_thread_struct::locking_mutex, Qfalse, rb_mutex_struct::th, and thread_cleanup_func_before_exec().

Referenced by terminate_atfork_i().

static void thread_cleanup_func_before_exec | ( | void * | th_ptr | ) | `[static]`

Definition at line 381 of file thread.c.

References rb_thread_struct::machine_stack_end, rb_thread_struct::machine_stack_start, rb_thread_struct::status, rb_mutex_struct::th, and THREAD_KILLED.

Referenced by terminate_atfork_before_exec_i(), and thread_cleanup_func().

static VALUE thread_create_core | ( | VALUE | thval,
|  | VALUE | args,
|  | VALUE(*)(ANYARGS) | fn
| ) |  | `[static]`

Definition at line 534 of file thread.c.

References err, rb_thread_struct::event_flags, rb_thread_struct::first_args, rb_thread_struct::first_func, rb_thread_struct::first_proc, GET_THREAD, GET_VM, GetThreadPtr, rb_thread_struct::interrupt_lock, rb_vm_struct::living_threads, NULL, OBJ_FROZEN, rb_thread_struct::priority, Qfalse, rb_block_proc(), rb_eThreadError, rb_raise(), RUBY_EVENT_VM, rb_thread_struct::self, st_delete_wrap(), st_insert, rb_thread_struct::status, rb_mutex_struct::th, rb_thread_struct::thgroup, rb_thread_struct::thread_id, THREAD_KILLED, and rb_thread_struct::vm.

Referenced by rb_thread_create(), thread_initialize(), and thread_start().

static VALUE thread_initialize | ( | VALUE | thread,
|  | VALUE | args
| ) |  | `[static]`

Definition at line 601 of file thread.c.

References rb_thread_struct::first_args, rb_thread_struct::first_proc, GetThreadPtr, NIL_P, NUM2INT, RARRAY_PTR, rb_block_given_p(), rb_eThreadError, rb_proc_location(), rb_raise(), RSTRING_PTR, RTEST, rb_mutex_struct::th, and thread_create_core().

Referenced by Init_Thread().

static VALUE thread_join | ( | rb_thread_t * | target_th,
|  | double | delay
| ) |  | `[static]`

Definition at line 690 of file thread.c.

References DELAY_INFTY, err, rb_thread_struct::errinfo, FIXNUM_P, join_arg::forever, GET_THREAD, GET_THROWOBJ_STATE, GET_THROWOBJ_VAL, rb_thread_struct::join_list_head, rb_thread_struct::join_list_next, join_arg::limit, Qnil, rb_ensure(), rb_exc_raise(), rb_vm_make_jump_tag_but_local_jump(), remove_from_join_list(), rb_thread_struct::self, rb_thread_struct::status, T_NODE, join_arg::target, thread_debug, rb_thread_struct::thread_id, thread_join_sleep(), THREAD_KILLED, timeofday(), TYPE, and join_arg::waiting.

Referenced by thread_join_m(), and thread_value().

static VALUE thread_join_m | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  | `[static]`

Definition at line 773 of file thread.c.

References DELAY_INFTY, GetThreadPtr, join_arg::limit, NIL_P, rb_num2dbl(), rb_scan_args(), and thread_join().

Referenced by Init_Thread().

static VALUE thread_join_sleep | ( | VALUE | arg | ) | `[static]`

Definition at line 664 of file thread.c.

References join_arg::forever, join_arg::limit, Qfalse, Qtrue, sleep_forever(), sleep_wait_for_interrupt(), rb_thread_struct::status, join_arg::target, thread_debug, rb_thread_struct::thread_id, THREAD_KILLED, timeofday(), and join_arg::waiting.

Referenced by thread_join().

static int thread_keys_i | ( | ID | key,
|  | VALUE | value,
|  | VALUE | ary
| ) |  | `[static]`

Definition at line 2096 of file thread.c.

References ID2SYM, rb_ary_push(), and ST_CONTINUE.

Referenced by rb_thread_keys().

static int thread_list_i | ( | st_data_t | key,
|  | st_data_t | val,
|  | void * | data
| ) |  | `[static]`

Definition at line 1622 of file thread.c.

References GetThreadPtr, rb_ary_push(), rb_thread_struct::self, ST_CONTINUE, rb_thread_struct::status, THREAD_RUNNABLE, THREAD_STOPPED, THREAD_STOPPED_FOREVER, and THREAD_TO_KILL.

Referenced by rb_thread_list().

static VALUE thread_raise_m | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  | `[static]`

Definition at line 1446 of file thread.c.

References GetThreadPtr, Qnil, and rb_threadptr_raise().

Referenced by Init_Thread().

static void thread_reset_event_flags | ( | rb_thread_t * | th | ) | `[static]`

Definition at line 3715 of file thread.c.

References rb_thread_struct::event_flags, rb_thread_struct::event_hooks, rb_event_hook_struct::flag, rb_event_hook_struct::next, and RUBY_EVENT_VM.

Referenced by rb_threadptr_add_event_hook(), and rb_threadptr_revmove_event_hook().

static VALUE thread_s_current | ( | VALUE | klass | ) | `[static]`

Definition at line 1686 of file thread.c.

References rb_thread_current().

Referenced by Init_Thread().

static VALUE thread_s_new | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  | `[static]`

Definition at line 570 of file thread.c.

References rb_thread_struct::first_args, GetThreadPtr, rb_class2name(), rb_eThreadError, rb_obj_call_init(), rb_raise(), rb_thread_alloc(), and rb_mutex_struct::th.

Referenced by Init_Thread().

static VALUE thread_s_pass | ( | VALUE | klass | ) | `[static]`

Definition at line 1244 of file thread.c.

References Qnil, and rb_thread_schedule().

Referenced by Init_Thread().

static VALUE thread_set_trace_func_m | ( | VALUE | obj,
|  | VALUE | trace
| ) |  | `[static]`

Definition at line 3985 of file thread.c.

References call_trace_func(), GetThreadPtr, NIL_P, Qnil, rb_threadptr_revmove_event_hook(), and thread_add_trace_func().

Referenced by Init_Thread().

static VALUE thread_start | ( | VALUE | klass,
|  | VALUE | args
| ) |  | `[static]`

Definition at line 594 of file thread.c.

References rb_thread_alloc(), and thread_create_core().

Referenced by Init_Thread().

static int thread_start_func_2 | ( | rb_thread_t * | th,
|  | VALUE * | stack_start,
|  | VALUE * | register_stack_start
| ) |  | `[static]`

Definition at line 412 of file thread.c.

References rb_proc_t::block, EXEC_TAG, rb_thread_struct::first_args, GetProcPtr, rb_thread_struct::join_list_head, rb_thread_struct::join_list_next, rb_block_struct::lfp, rb_thread_struct::machine_stack_start, rb_vm_struct::main_thread, NIL_P, PRIxVALUE, Qfalse, Qnil, RARRAY_LEN, RARRAY_PTR, rb_bug(), rb_errinfo, rb_eSecurityError, rb_eSystemExit, rb_exc_new3(), rb_obj_is_kind_of(), rb_sprintf(), rb_thread_recycle_stack_release(), rb_thread_set_current, rb_threadptr_interrupt(), rb_threadptr_raise(), rb_vm_invoke_proc(), RTEST, ruby_debug, SAVE_ROOT_JMPBUF, rb_block_struct::self, st_delete_wrap(), rb_thread_struct::status, T_OBJECT, TAG_FATAL, TH_POP_TAG, TH_PUSH_TAG, thread_debug, THREAD_KILLED, THREAD_RUNNABLE, THREAD_STOPPED, THREAD_STOPPED_FOREVER, TYPE, and rb_thread_struct::vm.

static const char* thread_status_name | ( | enum rb_thread_status | status | ) | `[static]`

Definition at line 1827 of file thread.c.

References THREAD_KILLED, THREAD_RUNNABLE, THREAD_STOPPED, THREAD_STOPPED_FOREVER, and THREAD_TO_KILL.

Referenced by rb_thread_inspect(), rb_thread_status(), and rb_threadptr_check_signal().

static void thread_unlock_all_locking_mutexes | ( | rb_thread_t * | th | ) | `[static]`

Definition at line 372 of file thread.c.

References rb_thread_struct::keeping_mutexes, NULL, and rb_mutex_unlock_all().

static VALUE thread_value | ( | VALUE | self | ) | `[static]`

Definition at line 801 of file thread.c.

References DELAY_INFTY, GetThreadPtr, thread_join(), and rb_thread_struct::value.

Referenced by Init_Thread().

static rb_thread_t* thval2thread_t | ( | VALUE | thval | ) | `[static]`

Definition at line 3738 of file thread.c.

References GetThreadPtr.

Referenced by rb_thread_add_event_hook(), and rb_thread_remove_event_hook().

static double timeofday | ( | void |  | ) | `[static]`

Definition at line 910 of file thread.c.

References gettimeofday(), NULL, timespec::tv_nsec, timeval::tv_sec, timespec::tv_sec, and timeval::tv_usec.

Referenced by do_select(), thread_join(), and thread_join_sleep().

static void timer_thread_function | ( | void * | arg | ) | `[static]`

Definition at line 2678 of file thread.c.

References GET_VM, rb_vm_struct::main_thread, rb_threadptr_check_signal(), RUBY_VM_SET_TIMER_INTERRUPT, and rb_vm_struct::running_thread.

static void update_coverage | ( | rb_event_flag_t | event,
|  | VALUE | proc,
|  | VALUE | self,
|  | ID | id,
|  | VALUE | klass
| ) |  | `[static]`

Definition at line 4342 of file thread.c.

References count, coverage(), FIX2LONG, GET_THREAD, LONG2FIX, POSFIXABLE, Qnil, RARRAY_PTR, rb_bug(), rb_sourceline(), and RBASIC.

Referenced by rb_reset_coverages(), and rb_set_coverages().

static int vm_living_thread_num | ( | rb_vm_t * | vm | ) | `[static]`

Definition at line 2103 of file thread.c.

References rb_vm_struct::living_threads, and st_table::num_entries.

Referenced by rb_check_deadlock(), rb_mutex_lock(), and rb_thread_alone().

## Variable Documentation

const rb_data_type_t barrier_data_type`[static]`

Initial value:

     {
        "barrier",
        barrier_mark, 0, 0,
    }

Definition at line 3425 of file thread.c.

const VALUE eKillSignal = INT2FIX(0)`[static]`

Definition at line 77 of file thread.c.

Referenced by rb_thread_kill(), and rb_threadptr_execute_interrupts_rec().

const VALUE eTerminateSignal = INT2FIX(1)`[static]`

Definition at line 78 of file thread.c.

Referenced by rb_threadptr_execute_interrupts_rec(), and terminate_i().

const rb_data_type_t mutex_data_type`[static]`

Initial value:

     {
        "mutex",
        mutex_mark, mutex_free, mutex_memsize,
    }

Definition at line 3054 of file thread.c.

VALUE rb_cBarrier

Definition at line 61 of file thread.c.

Referenced by rb_barrier_new().

VALUE rb_cMutex

Definition at line 60 of file thread.c.

Referenced by Init_Thread(), rb_mutex_new(), and rb_objspace_call_finalizer().

ID recursive_key`[static]`

Definition at line 3476 of file thread.c.

volatile int system_working = 1`[static]`

Definition at line 79 of file thread.c.

Referenced by rb_thread_start_timer_thread().

const rb_data_type_t thgroup_data_type`[static]`

Initial value:

     {
        "thgroup",
        NULL, RUBY_TYPED_DEFAULT_FREE, thgroup_memsize,
    }

Definition at line 2816 of file thread.c.

Referenced by thgroup_add(), thgroup_enclose(), thgroup_enclosed_p(), and thgroup_s_alloc().