Ruby: internal/thread.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros | Functions
thread.h File Reference

Internal header for Thread. More...

`#include "ruby/ruby.h"`
`#include "ruby/intern.h"`

Go to the source code of this file.

## Macros
#define | COVERAGE_INDEX_LINES 0
#define | COVERAGE_INDEX_BRANCHES 1
#define | COVERAGE_TARGET_LINES 1
#define | COVERAGE_TARGET_BRANCHES 2
#define | COVERAGE_TARGET_METHODS 4
#define | COVERAGE_TARGET_ONESHOT_LINES 8

## Functions
VALUE | rb_obj_is_mutex (VALUE obj)
VALUE | rb_suppress_tracing (VALUE(*func)(VALUE), VALUE arg)
void | rb_thread_execute_interrupts (VALUE th)
VALUE | rb_get_coverages (void)
int | rb_get_coverage_mode (void)
VALUE | rb_default_coverage (int)
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)
int | rb_thread_to_be_killed (VALUE thread)
void | rb_mutex_allow_trap (VALUE self, int val)
VALUE | rb_uninterruptible (VALUE(*b_proc)(VALUE), VALUE data)
VALUE | rb_mutex_owned_p (VALUE self)
int | rb_thread_wait_for_single_fd (int fd, int events, struct timeval *timeout)
VALUE | rb_thread_io_blocking_region (rb_blocking_function_t *func, void *data1, int fd)
int | ruby_thread_has_gvl_p (void)
int | rb_threadptr_execute_interrupts (struct rb_thread_struct *th, int blocking_timing)

## Detailed Description

Internal header for Thread.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Definition in file thread.h.

## Macro Definition Documentation

## ◆ COVERAGE_INDEX_BRANCHES

#define COVERAGE_INDEX_BRANCHES 1

Definition at line 19 of file thread.h.

## ◆ COVERAGE_INDEX_LINES

#define COVERAGE_INDEX_LINES 0

Definition at line 18 of file thread.h.

## ◆ COVERAGE_TARGET_BRANCHES

#define COVERAGE_TARGET_BRANCHES 2

Definition at line 21 of file thread.h.

## ◆ COVERAGE_TARGET_LINES

#define COVERAGE_TARGET_LINES 1

Definition at line 20 of file thread.h.

## ◆ COVERAGE_TARGET_METHODS

#define COVERAGE_TARGET_METHODS 4

Definition at line 22 of file thread.h.

## ◆ COVERAGE_TARGET_ONESHOT_LINES

#define COVERAGE_TARGET_ONESHOT_LINES 8

Definition at line 23 of file thread.h.

## Function Documentation

## ◆ rb_default_coverage()

VALUE rb_default_coverage | ( | int | n | ) |

Definition at line 5815 of file thread.c.

References COVERAGE_INDEX_BRANCHES, COVERAGE_INDEX_LINES, COVERAGE_TARGET_BRANCHES, COVERAGE_TARGET_LINES, Qfalse, rb_ary_tmp_new(), rb_ary_tmp_new_fill(), rb_hash_new(), and rb_obj_hide().

Referenced by rb_iseq_new_top().

## ◆ rb_get_coverage_mode()

int rb_get_coverage_mode | ( | void |  | ) |

Definition at line 5779 of file thread.c.

Referenced by rb_iseq_new_top().

## ◆ rb_get_coverages()

VALUE rb_get_coverages | ( | void |  | ) |

Definition at line 5773 of file thread.c.

Referenced by rb_iseq_new_top().

## ◆ rb_mutex_allow_trap()

void rb_mutex_allow_trap | ( | VALUE | self,
|  | int | val
| ) |  |

Definition at line 621 of file thread_sync.c.

References Check_TypedStruct, FL_SET_RAW, FL_UNSET_RAW, and MUTEX_ALLOW_TRAP.

## ◆ rb_mutex_owned_p()

VALUE rb_mutex_owned_p | ( | VALUE | self | ) |

Definition at line 414 of file thread_sync.c.

References sync_waiter::fiber, and sync_waiter::self.

## ◆ rb_obj_is_mutex()

VALUE rb_obj_is_mutex | ( | VALUE | obj | ) |

Definition at line 142 of file thread_sync.c.

References Qfalse, Qtrue, and rb_typeddata_is_kind_of().

Referenced by rb_objspace_call_finalizer().

## ◆ rb_suppress_tracing()

VALUE rb_suppress_tracing | ( | VALUE(*)(VALUE) | func,
|  | VALUE | arg
| ) |  |

Definition at line 418 of file vm_trace.c.

References EC_EXEC_TAG, EC_JUMP_TAG, EC_POP_TAG, EC_PUSH_TAG, rb_trace_arg_struct::event, LIKELY, NULL, Qnil, rb_ec_reset_raised(), RB_GC_GUARD, TAG_NONE, and rb_execution_context_struct::trace_arg.

## ◆ rb_thread_execute_interrupts()

void rb_thread_execute_interrupts | ( | VALUE | th | ) |

Definition at line 2525 of file thread.c.

References rb_threadptr_execute_interrupts().

Referenced by rb_f_kill().

## ◆ rb_thread_io_blocking_region()

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

Definition at line 1815 of file thread.c.

References BLOCKING_REGION, COROUTINE_STACK_FREE, COROUTINE_STACK_LOCAL, EC_EXEC_TAG, EC_JUMP_TAG, EC_POP_TAG, EC_PUSH_TAG, FALSE, Qundef, RB_VM_LOCK_ENTER, RB_VM_LOCK_LEAVE, RUBY_VM_CHECK_INTS_BLOCKING, and TAG_NONE.

## ◆ rb_thread_shield_destroy()

VALUE rb_thread_shield_destroy | ( | VALUE | self | ) |

Definition at line 5128 of file thread.c.

References DATA_PTR, Qfalse, Qtrue, and rb_mutex_unlock().

## ◆ rb_thread_shield_new()

VALUE rb_thread_shield_new | ( | void |  | ) |

Definition at line 5072 of file thread.c.

References DATA_PTR, and rb_mutex_lock().

## ◆ rb_thread_shield_release()

VALUE rb_thread_shield_release | ( | VALUE | self | ) |

Definition at line 5117 of file thread.c.

References Qfalse, Qtrue, and rb_mutex_unlock().

## ◆ rb_thread_shield_wait()

VALUE rb_thread_shield_wait | ( | VALUE | self | ) |

Definition at line 5088 of file thread.c.

References DATA_PTR, rb_mutex_struct::fiber, GetThreadShieldPtr, Qfalse, Qnil, Qtrue, rb_mutex_lock(), and rb_mutex_unlock().

## ◆ rb_thread_to_be_killed()

int rb_thread_to_be_killed | ( | VALUE | thread | ) |

Definition at line 2720 of file thread.c.

References FALSE, THREAD_KILLED, rb_thread_struct::to_kill, and TRUE.

## ◆ rb_thread_wait_for_single_fd()

int rb_thread_wait_for_single_fd | ( | int | fd,
|  | int | events,
|  | struct timeval * | timeout
| ) |  |

Definition at line 4551 of file thread.c.

References select_args::as, select_args::error, select_args::except, waiting_fd::fd, select_args::fd, int(), NULL, ptr, rb_ensure(), RB_VM_LOCK_ENTER, RB_VM_LOCK_LEAVE, RB_WAITFD_IN, RB_WAITFD_OUT, RB_WAITFD_PRI, select_args::read, waiting_fd::th, select_args::timeout, select_args::tv, rb_thread_struct::vm, rb_vm_struct::waiting_fds, select_args::wfd, waiting_fd::wfd_node, and select_args::write.

Referenced by rb_io_wait(), and rb_wait_for_single_fd().

## ◆ rb_threadptr_execute_interrupts()

int rb_threadptr_execute_interrupts | ( | struct rb_thread_struct * | th,
|  | int | blocking_timing
| ) |  |

Definition at line 2424 of file thread.c.

References rb_execution_context_struct::cfp, rb_thread_struct::ec, eKillSignal, err, eTerminateSignal, EXEC_EVENT_HOOK, FALSE, INT2FIX, INTERRUPT_NONE, INTERRUPT_ON_BLOCKING, rb_vm_struct::main_thread, PENDING_INTERRUPT_MASK, POSTPONED_JOB_INTERRUPT_MASK, rb_blocking_region_buffer::prev_status, PRIdVALUE, rb_thread_struct::priority, Qundef, rb_vm_struct::ractor, rb_execution_context_struct::raised_flag, rb_exc_raise(), rb_get_next_signal(), rb_postponed_job_flush(), rb_signal_exec(), rb_sigwait_fd_get(), rb_sigwait_fd_migrate(), rb_sigwait_fd_put(), RB_VM_LOCK_ENTER, RB_VM_LOCK_LEAVE, ruby_error_stream_closed, RUBY_INTERNAL_EVENT_SWITCH, ruby_sigchld_handler(), ruby_vm_special_exception_copy(), rb_thread_struct::running_time_us, rb_control_frame_struct::self, rb_vm_struct::special_exceptions, TAG_FATAL, TERMINATE_INTERRUPT_MASK, thread_debug, THREAD_RUNNABLE, THREAD_STOPPED, THREAD_STOPPED_FOREVER, TIMER_INTERRUPT_MASK, TRAP_INTERRUPT_MASK, TRUE, rb_thread_struct::vm, VM_ASSERT, and VM_BARRIER_INTERRUPT_MASK.

## ◆ rb_uninterruptible()

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

Definition at line 5874 of file thread.c.

References rb_thread_struct::ec, OBJ_FREEZE_RAW, rb_thread_struct::pending_interrupt_mask_stack, Qnil, rb_ary_push(), rb_cObject, rb_ensure(), rb_hash_aset(), rb_ident_hash_new(), and RUBY_VM_CHECK_INTS.

## ◆ ruby_thread_has_gvl_p()

int ruby_thread_has_gvl_p | ( | void |  | ) |

Definition at line 1935 of file thread.c.