Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
Macros | Typedefs | Functions
thread.h File Reference

Public APIs related to rb_cThread. More...

#include "ruby/internal/config.h"
#include "ruby/internal/cast.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/value.h"

Go to the source code of this file.

Macros

#define RUBY_UBF_IO   RBIMPL_CAST((rb_unblock_function_t *)-1)
 
#define RUBY_UBF_PROCESS   RBIMPL_CAST((rb_unblock_function_t *)-1)
 

Typedefs

typedef void rb_unblock_function_t(void *)
 
typedef VALUE rb_blocking_function_t(void *)
 

Functions

void rb_thread_schedule (void)
 
void rb_thread_wait_fd (int)
 
int rb_thread_fd_writable (int)
 
void rb_thread_fd_close (int)
 
int rb_thread_alone (void)
 
void rb_thread_sleep (int)
 
void rb_thread_sleep_forever (void)
 
void rb_thread_sleep_deadly (void)
 
VALUE rb_thread_stop (void)
 
VALUE rb_thread_wakeup (VALUE)
 
VALUE rb_thread_wakeup_alive (VALUE)
 
VALUE rb_thread_run (VALUE)
 
VALUE rb_thread_kill (VALUE)
 
VALUE rb_thread_create (VALUE(*)(void *), void *)
 
void rb_thread_wait_for (struct timeval)
 
VALUE rb_thread_current (void)
 
VALUE rb_thread_main (void)
 
VALUE rb_thread_local_aref (VALUE, ID)
 
VALUE rb_thread_local_aset (VALUE, ID, VALUE)
 
void rb_thread_atfork (void)
 
void rb_thread_atfork_before_exec (void)
 
VALUE rb_exec_recursive (VALUE(*)(VALUE, VALUE, int), VALUE, VALUE)
 
VALUE rb_exec_recursive_paired (VALUE(*)(VALUE, VALUE, int), VALUE, VALUE, VALUE)
 
VALUE rb_exec_recursive_outer (VALUE(*)(VALUE, VALUE, int), VALUE, VALUE)
 
VALUE rb_exec_recursive_paired_outer (VALUE(*)(VALUE, VALUE, int), VALUE, VALUE, VALUE)
 
void rb_thread_check_ints (void)
 
int rb_thread_interrupted (VALUE thval)
 
VALUE rb_mutex_new (void)
 
VALUE rb_mutex_locked_p (VALUE mutex)
 
VALUE rb_mutex_trylock (VALUE mutex)
 
VALUE rb_mutex_lock (VALUE mutex)
 
VALUE rb_mutex_unlock (VALUE mutex)
 
VALUE rb_mutex_sleep (VALUE self, VALUE timeout)
 
VALUE rb_mutex_synchronize (VALUE mutex, VALUE(*func)(VALUE arg), VALUE arg)
 

Detailed Description

Public APIs related to rb_cThread.

Author
Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org
Warning
Symbols prefixed with either RBIMPL or rbimpl are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.
Note
To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance __VA_ARGS__ is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file thread.h.

Macro Definition Documentation

◆ RUBY_UBF_IO

#define RUBY_UBF_IO   RBIMPL_CAST((rb_unblock_function_t *)-1)

Definition at line 64 of file thread.h.

◆ RUBY_UBF_PROCESS

#define RUBY_UBF_PROCESS   RBIMPL_CAST((rb_unblock_function_t *)-1)

Definition at line 65 of file thread.h.

Typedef Documentation

◆ rb_blocking_function_t

typedef VALUE rb_blocking_function_t(void *)

Definition at line 60 of file thread.h.

◆ rb_unblock_function_t

typedef void rb_unblock_function_t(void *)

Definition at line 59 of file thread.h.

Function Documentation

◆ rb_exec_recursive()

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

◆ rb_exec_recursive_outer()

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

Definition at line 5383 of file thread.c.

References exec_recursive_params::arg, exec_recursive_params::func, and exec_recursive_params::obj.

Referenced by rb_hash().

◆ rb_exec_recursive_paired()

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

◆ rb_exec_recursive_paired_outer()

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

◆ rb_mutex_lock()

VALUE rb_mutex_lock ( VALUE  mutex)

Definition at line 402 of file thread_sync.c.

References sync_waiter::self.

Referenced by rb_mutex_synchronize(), rb_thread_shield_new(), and rb_thread_shield_wait().

◆ rb_mutex_locked_p()

VALUE rb_mutex_locked_p ( VALUE  mutex)

Definition at line 189 of file thread_sync.c.

References rb_mutex_struct::fiber, Qfalse, Qtrue, and sync_waiter::self.

◆ rb_mutex_new()

VALUE rb_mutex_new ( void  )

Definition at line 177 of file thread_sync.c.

◆ rb_mutex_sleep()

VALUE rb_mutex_sleep ( VALUE  self,
VALUE  timeout 
)

◆ rb_mutex_synchronize()

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

Definition at line 598 of file thread_sync.c.

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

◆ rb_mutex_trylock()

VALUE rb_mutex_trylock ( VALUE  mutex)

◆ rb_mutex_unlock()

VALUE rb_mutex_unlock ( VALUE  mutex)

◆ rb_thread_alone()

int rb_thread_alone ( void  )

Definition at line 3757 of file thread.c.

References rb_ractor_living_thread_num().

Referenced by rb_thread_stop().

◆ rb_thread_atfork()

void rb_thread_atfork ( void  )

Definition at line 4830 of file thread.c.

◆ rb_thread_atfork_before_exec()

void rb_thread_atfork_before_exec ( void  )

Definition at line 4835 of file thread.c.

◆ rb_thread_check_ints()

void rb_thread_check_ints ( void  )

Definition at line 1577 of file thread.c.

References RUBY_VM_CHECK_INTS_BLOCKING.

Referenced by rb_io_wait_readable(), and rb_io_wait_writable().

◆ rb_thread_create()

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

◆ rb_thread_current()

VALUE rb_thread_current ( void  )

Definition at line 2911 of file thread.c.

Referenced by rb_autoload_load(), rb_f_kill(), VpGetPrecLimit(), and VpGetRoundMode().

◆ rb_thread_fd_close()

void rb_thread_fd_close ( int  fd)

Definition at line 2634 of file thread.c.

References rb_notify_fd_close(), and rb_thread_schedule().

◆ rb_thread_fd_writable()

int rb_thread_fd_writable ( int  fd)

Definition at line 4311 of file thread.c.

References TRUE.

Referenced by rb_io_wait_writable().

◆ rb_thread_interrupted()

int rb_thread_interrupted ( VALUE  thval)

Definition at line 1594 of file thread.c.

References RUBY_VM_INTERRUPTED.

◆ rb_thread_kill()

VALUE rb_thread_kill ( VALUE  thread)

◆ rb_thread_local_aref()

VALUE rb_thread_local_aref ( VALUE  thread,
ID  id 
)

Definition at line 3480 of file thread.c.

Referenced by VpGetPrecLimit(), and VpGetRoundMode().

◆ rb_thread_local_aset()

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

Definition at line 3628 of file thread.c.

References OBJ_FROZEN, and rb_frozen_error_raise().

Referenced by rb_detach_process().

◆ rb_thread_main()

VALUE rb_thread_main ( void  )

Definition at line 2932 of file thread.c.

◆ rb_thread_run()

VALUE rb_thread_run ( VALUE  thread)

Definition at line 2835 of file thread.c.

References rb_thread_schedule(), and rb_thread_wakeup().

Referenced by Init_Thread().

◆ rb_thread_schedule()

void rb_thread_schedule ( void  )

Definition at line 1623 of file thread.c.

References RUBY_VM_CHECK_INTS.

Referenced by rb_thread_fd_close(), and rb_thread_run().

◆ rb_thread_sleep()

void rb_thread_sleep ( int  sec)

Definition at line 1600 of file thread.c.

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

◆ rb_thread_sleep_deadly()

void rb_thread_sleep_deadly ( void  )

Definition at line 1531 of file thread.c.

References SLEEP_DEADLOCKABLE, SLEEP_SPURIOUS_CHECK, and thread_debug.

Referenced by rb_thread_stop().

◆ rb_thread_sleep_forever()

void rb_thread_sleep_forever ( void  )

Definition at line 1524 of file thread.c.

References SLEEP_SPURIOUS_CHECK, and thread_debug.

Referenced by rb_thread_fd_select().

◆ rb_thread_stop()

VALUE rb_thread_stop ( void  )

Definition at line 2844 of file thread.c.

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

◆ rb_thread_wait_fd()

void rb_thread_wait_fd ( int  fd)

Definition at line 4305 of file thread.c.

Referenced by rb_io_read_check(), and rb_io_wait_readable().

◆ rb_thread_wait_for()

void rb_thread_wait_for ( struct timeval  time)

Definition at line 1562 of file thread.c.

References SLEEP_SPURIOUS_CHECK.

Referenced by rb_thread_fd_select(), and rb_thread_sleep().

◆ rb_thread_wakeup()

VALUE rb_thread_wakeup ( VALUE  thread)

Definition at line 2788 of file thread.c.

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

Referenced by Init_Thread(), and rb_thread_run().

◆ rb_thread_wakeup_alive()

VALUE rb_thread_wakeup_alive ( VALUE  thread)

Definition at line 2797 of file thread.c.

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

Referenced by rb_thread_wakeup().