Ruby  2.5.0dev(2017-10-22revision60238)
Data Structures | Macros | Typedefs | Functions
thread_sync.c File Reference
#include "ccan/list/list.h"

Go to the source code of this file.

Data Structures

struct  sync_waiter
 
struct  rb_mutex_struct
 
struct  queue_waiter
 
struct  rb_condvar
 
struct  sleep_call
 

Macros

#define MUTEX_ALLOW_TRAP   FL_USER1
 
#define GetMutexPtr(obj, tobj)   TypedData_Get_Struct((obj), rb_mutex_t, &mutex_data_type, (tobj))
 
#define mutex_mark   NULL
 
#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 ALIAS_GLOBAL_CONST(name)   alias_global_const(#name, rb_c##name)
 

Typedefs

typedef struct rb_mutex_struct rb_mutex_t
 

Functions

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;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

◆ ALIAS_GLOBAL_CONST

#define ALIAS_GLOBAL_CONST (   name)    alias_global_const(#name, rb_c##name)

◆ GetMutexPtr

#define GetMutexPtr (   obj,
  tobj 
)    TypedData_Get_Struct((obj), rb_mutex_t, &mutex_data_type, (tobj))

◆ MUTEX_ALLOW_TRAP

#define MUTEX_ALLOW_TRAP   FL_USER1

Definition at line 13 of file thread_sync.c.

Referenced by rb_mutex_allow_trap(), and rb_mutex_lock().

◆ mutex_mark

#define mutex_mark   NULL

Definition at line 87 of file thread_sync.c.

◆ QUEUE_CLOSED

#define QUEUE_CLOSED   FL_USER5

Definition at line 580 of file thread_sync.c.

◆ queue_waitq

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

Definition at line 523 of file thread_sync.c.

◆ szqueue_pushq

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

Definition at line 531 of file thread_sync.c.

◆ szqueue_waitq

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

Definition at line 530 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;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;}  )

◆ rb_mutex_allow_trap()

void rb_mutex_allow_trap ( VALUE  self,
int  val 
)

Definition at line 511 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)

◆ rb_mutex_locked_p()

VALUE rb_mutex_locked_p ( VALUE  self)

Definition at line 173 of file thread_sync.c.

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

◆ rb_mutex_new()

VALUE rb_mutex_new ( void  )

Definition at line 161 of file thread_sync.c.

◆ rb_mutex_owned_p()

VALUE rb_mutex_owned_p ( VALUE  self)

Definition at line 306 of file thread_sync.c.

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

◆ rb_mutex_sleep()

VALUE rb_mutex_sleep ( VALUE  self,
VALUE  timeout 
)

Definition at line 436 of file thread_sync.c.

References NIL_P, rb_ensure(), rb_mutex_unlock(), and rb_time_interval().

◆ rb_mutex_synchronize()

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

Definition at line 488 of file thread_sync.c.

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

◆ rb_mutex_trylock()

VALUE rb_mutex_trylock ( VALUE  self)

Definition at line 200 of file thread_sync.c.

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

Referenced by rb_mutex_lock().

◆ rb_mutex_unlock()

VALUE rb_mutex_unlock ( VALUE  self)

Definition at line 370 of file thread_sync.c.

References err, and GetMutexPtr.

Referenced by rb_mutex_sleep(), and rb_mutex_synchronize().

◆ rb_obj_is_mutex()

VALUE rb_obj_is_mutex ( VALUE  obj)

Definition at line 127 of file thread_sync.c.

References Qfalse, Qtrue, and rb_typeddata_is_kind_of().