Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
Data Structures | Macros | Typedefs | Functions
thread_sync.c File Reference
#include "ccan/list/list.h"
#include "coroutine/Stack.h"

Go to the source code of this file.

Data Structures

struct  rb_mutex_struct
 
struct  sync_waiter
 
struct  queue_waiter
 
struct  rb_condvar
 
struct  sleep_call
 

Macros

#define MUTEX_ALLOW_TRAP   FL_USER1
 
#define mutex_mark   ((void(*)(void*))0)
 
#define queue_waitq(q)   UNALIGNED_MEMBER_PTR(q, waitq)
 
#define szqueue_waitq(sq)   UNALIGNED_MEMBER_PTR(sq, q.waitq)
 
#define szqueue_pushq(sq)   UNALIGNED_MEMBER_PTR(sq, pushq)
 
#define QUEUE_CLOSED   FL_USER5
 
#define DEFINE_CLASS(name, super)    rb_c##name = define_thread_class(rb_cThread, #name, rb_c##super)
 

Typedefs

typedef struct rb_mutex_struct rb_mutex_t
 

Functions

rb_thread_trb_fiber_threadptr (const rb_fiber_t *fiber)
 
VALUE rb_obj_is_mutex (VALUE obj)
 
VALUE rb_mutex_new (void)
 
VALUE rb_mutex_locked_p (VALUE self)
 
VALUE rb_mutex_trylock (VALUE self)
 
VALUE rb_mutex_lock (VALUE self)
 
VALUE rb_mutex_owned_p (VALUE self)
 
VALUE rb_mutex_unlock (VALUE self)
 
VALUE rb_mutex_sleep (VALUE self, VALUE timeout)
 
VALUE rb_mutex_synchronize (VALUE mutex, VALUE(*func)(VALUE arg), VALUE arg)
 
void rb_mutex_allow_trap (VALUE self, int val)
 
 PACKED_STRUCT_UNALIGNED (struct rb_queue { struct list_head waitq;rb_serial_t fork_gen;const VALUE que;int num_waiting;})
 
 PACKED_STRUCT_UNALIGNED (struct rb_szqueue { struct rb_queue q;int num_waiting_push;struct list_head pushq;long max;})
 

Macro Definition Documentation

◆ DEFINE_CLASS

#define DEFINE_CLASS (   name,
  super 
)     rb_c##name = define_thread_class(rb_cThread, #name, rb_c##super)

◆ MUTEX_ALLOW_TRAP

#define MUTEX_ALLOW_TRAP   FL_USER1

Definition at line 23 of file thread_sync.c.

◆ mutex_mark

#define mutex_mark   ((void(*)(void*))0)

Definition at line 90 of file thread_sync.c.

◆ QUEUE_CLOSED

#define QUEUE_CLOSED   FL_USER5

Definition at line 708 of file thread_sync.c.

◆ queue_waitq

#define queue_waitq (   q)    UNALIGNED_MEMBER_PTR(q, waitq)

Definition at line 633 of file thread_sync.c.

◆ szqueue_pushq

#define szqueue_pushq (   sq)    UNALIGNED_MEMBER_PTR(sq, pushq)

Definition at line 642 of file thread_sync.c.

◆ szqueue_waitq

#define szqueue_waitq (   sq)    UNALIGNED_MEMBER_PTR(sq, q.waitq)

Definition at line 641 of file thread_sync.c.

Typedef Documentation

◆ rb_mutex_t

typedef struct rb_mutex_struct rb_mutex_t

Function Documentation

◆ PACKED_STRUCT_UNALIGNED() [1/2]

PACKED_STRUCT_UNALIGNED ( struct rb_queue { struct list_head waitq;rb_serial_t fork_gen;const VALUE que;int num_waiting;}  )

◆ PACKED_STRUCT_UNALIGNED() [2/2]

PACKED_STRUCT_UNALIGNED ( struct rb_szqueue { struct rb_queue q;int num_waiting_push;struct list_head pushq;long max;}  )

References max.

◆ rb_fiber_threadptr()

rb_thread_t * rb_fiber_threadptr ( const rb_fiber_t fiber)

◆ 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_lock()

VALUE rb_mutex_lock ( VALUE  self)

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  self)

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_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_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  self)

◆ rb_mutex_unlock()

VALUE rb_mutex_unlock ( VALUE  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().