Ruby
2.4.2p198(2017-09-14revision59899)
|
Go to the source code of this file.
Data Structures | |
struct | rb_mutex_struct |
struct | waiting_delete |
struct | sleep_call |
Macros | |
#define | GetMutexPtr(obj, tobj) TypedData_Get_Struct((obj), rb_mutex_t, &mutex_data_type, (tobj)) |
#define | mutex_mark NULL |
#define | QUEUE_CLOSED FL_USER5 |
#define | GET_QUEUE_QUE(q) get_array((q), QUEUE_QUE) |
#define | GET_QUEUE_WAITERS(q) get_array((q), QUEUE_WAITERS) |
#define | GET_SZQUEUE_WAITERS(q) get_array((q), SZQUEUE_WAITERS) |
#define | GET_SZQUEUE_MAX(q) RSTRUCT_GET((q), SZQUEUE_MAX) |
#define | GET_SZQUEUE_ULONGMAX(q) NUM2ULONG(GET_SZQUEUE_MAX(q)) |
#define | GET_CONDVAR_WAITERS(cv) get_array((cv), CONDVAR_WAITERS) |
#define | ALIAS_GLOBAL_CONST(name) alias_global_const(#name, rb_c##name) |
Typedefs | |
typedef struct rb_mutex_struct | rb_mutex_t |
Enumerations | |
enum | { QUEUE_QUE, QUEUE_WAITERS, SZQUEUE_WAITERS, SZQUEUE_MAX, END_QUEUE } |
enum | { CONDVAR_WAITERS, END_CONDVAR } |
Variables | |
static VALUE | rb_cMutex |
static VALUE | rb_cQueue |
static VALUE | rb_cSizedQueue |
static VALUE | rb_cConditionVariable |
static VALUE | rb_eClosedQueueError |
static const rb_data_type_t | mutex_data_type |
static const rb_thread_t * | patrol_thread = NULL |
static ID | id_sleep |
#define ALIAS_GLOBAL_CONST | ( | name | ) | alias_global_const(#name, rb_c##name) |
Referenced by Init_thread_sync().
#define GET_CONDVAR_WAITERS | ( | cv | ) | get_array((cv), CONDVAR_WAITERS) |
Definition at line 1104 of file thread_sync.c.
Referenced by rb_condvar_broadcast(), rb_condvar_signal(), and rb_condvar_wait().
Definition at line 531 of file thread_sync.c.
Referenced by queue_do_pop(), queue_do_push(), queue_length(), rb_queue_clear(), and rb_szqueue_clear().
#define GET_QUEUE_WAITERS | ( | q | ) | get_array((q), QUEUE_WAITERS) |
Definition at line 532 of file thread_sync.c.
Referenced by queue_do_close(), queue_do_pop(), queue_do_push(), and queue_num_waiting().
#define GET_SZQUEUE_MAX | ( | q | ) | RSTRUCT_GET((q), SZQUEUE_MAX) |
Definition at line 534 of file thread_sync.c.
Referenced by rb_szqueue_max_get().
#define GET_SZQUEUE_ULONGMAX | ( | q | ) | NUM2ULONG(GET_SZQUEUE_MAX(q)) |
Definition at line 535 of file thread_sync.c.
Referenced by rb_szqueue_max_set(), rb_szqueue_push(), and szqueue_do_pop().
#define GET_SZQUEUE_WAITERS | ( | q | ) | get_array((q), SZQUEUE_WAITERS) |
Definition at line 533 of file thread_sync.c.
Referenced by queue_do_close(), rb_szqueue_clear(), rb_szqueue_max_set(), rb_szqueue_push(), szqueue_do_pop(), and szqueue_num_waiting_producer().
#define GetMutexPtr | ( | obj, | |
tobj | |||
) | TypedData_Get_Struct((obj), rb_mutex_t, &mutex_data_type, (tobj)) |
Definition at line 49 of file thread_sync.c.
Referenced by debug_deadlock_check(), mutex_locked(), rb_check_deadlock(), rb_mutex_allow_trap(), rb_mutex_lock(), rb_mutex_locked_p(), rb_mutex_owned_p(), rb_mutex_trylock(), rb_mutex_unlock(), and rb_thread_shield_wait().
#define mutex_mark NULL |
Definition at line 52 of file thread_sync.c.
#define QUEUE_CLOSED FL_USER5 |
Definition at line 529 of file thread_sync.c.
Referenced by queue_closed_p(), and queue_do_close().
typedef struct rb_mutex_struct rb_mutex_t |
anonymous enum |
Enumerator | |
---|---|
QUEUE_QUE | |
QUEUE_WAITERS | |
SZQUEUE_WAITERS | |
SZQUEUE_MAX | |
END_QUEUE |
Definition at line 521 of file thread_sync.c.
anonymous enum |
Enumerator | |
---|---|
CONDVAR_WAITERS | |
END_CONDVAR |
Definition at line 1099 of file thread_sync.c.
Definition at line 1231 of file thread_sync.c.
References rb_cObject, and rb_define_const().
|
static |
Definition at line 538 of file thread_sync.c.
References rb_ary_tmp_new().
Referenced by rb_condvar_initialize(), rb_queue_initialize(), and rb_szqueue_initialize().
Definition at line 1164 of file thread_sync.c.
References rb_ary_delete(), and rb_thread_current().
Referenced by rb_condvar_wait().
Definition at line 1157 of file thread_sync.c.
References sleep_call::mutex, rb_funcallv, and sleep_call::timeout.
Referenced by rb_condvar_wait().
Definition at line 544 of file thread_sync.c.
References PRIsVALUE, rb_eTypeError, rb_raise(), RB_TYPE_P, RSTRUCT_GET, and T_ARRAY.
|
static |
Definition at line 1237 of file thread_sync.c.
References ALIAS_GLOBAL_CONST, mutex_alloc(), mutex_initialize(), mutex_sleep(), NULL, rb_cConditionVariable, rb_cMutex, rb_cObject, rb_condvar_broadcast(), rb_condvar_initialize(), rb_condvar_signal(), rb_condvar_wait(), rb_cQueue, rb_cSizedQueue, rb_cThread, rb_define_alias(), rb_define_alloc_func(), rb_define_class(), rb_define_class_under(), rb_define_method(), rb_eClosedQueueError, rb_eStopIteration, rb_intern, rb_mutex_lock(), rb_mutex_locked_p(), rb_mutex_owned_p(), rb_mutex_synchronize_m(), rb_mutex_trylock(), rb_mutex_unlock(), rb_provide(), rb_queue_clear(), rb_queue_close(), rb_queue_closed_p(), rb_queue_empty_p(), rb_queue_initialize(), rb_queue_length(), rb_queue_num_waiting(), rb_queue_pop(), rb_queue_push(), rb_struct_alloc_noinit(), rb_struct_define_without_accessor_under(), rb_szqueue_clear(), rb_szqueue_close(), rb_szqueue_initialize(), rb_szqueue_max_get(), rb_szqueue_max_set(), rb_szqueue_num_waiting(), rb_szqueue_pop(), rb_szqueue_push(), rb_undef_method(), and undumpable().
Referenced by Init_Thread().
|
static |
Definition at line 177 of file thread_sync.c.
References rb_mutex_struct::cond, rb_mutex_struct::cond_waiting, err, ETIMEDOUT, rb_mutex_struct::lock, RUBY_VM_INTERRUPTED, rb_mutex_struct::th, timespec::tv_nsec, and timespec::tv_sec.
Referenced by rb_mutex_lock().
|
static |
Definition at line 217 of file thread_sync.c.
References rb_mutex_struct::cond, rb_mutex_struct::cond_waiting, and rb_mutex_struct::lock.
Referenced by rb_mutex_lock().
Definition at line 94 of file thread_sync.c.
References rb_mutex_struct::cond, rb_mutex_struct::lock, and TypedData_Make_Struct.
Referenced by Init_thread_sync(), rb_mutex_new(), and thread_shield_alloc().
|
static |
Definition at line 55 of file thread_sync.c.
References rb_mutex_struct::cond, err, rb_mutex_struct::lock, rb_bug(), rb_mutex_unlock_th(), ruby_xfree(), and rb_mutex_struct::th.
Definition at line 112 of file thread_sync.c.
Referenced by Init_thread_sync().
|
static |
Definition at line 138 of file thread_sync.c.
References GetMutexPtr, rb_thread_struct::keeping_mutexes, and rb_mutex_struct::next_mutex.
Referenced by rb_mutex_lock(), and rb_mutex_trylock().
|
static |
Definition at line 71 of file thread_sync.c.
Definition at line 471 of file thread_sync.c.
References rb_mutex_sleep(), and rb_scan_args().
Referenced by Init_thread_sync().
|
static |
Definition at line 598 of file thread_sync.c.
References FL_TEST_RAW, and QUEUE_CLOSED.
Referenced by queue_do_close(), queue_do_pop(), queue_do_push(), rb_queue_closed_p(), and rb_szqueue_push().
Definition at line 610 of file thread_sync.c.
References assert, Qnil, and queue_length().
Referenced by queue_do_pop().
|
static |
Definition at line 767 of file thread_sync.c.
References Qnil, rb_ary_delete(), waiting_delete::th, and waiting_delete::waiting.
Referenced by queue_do_pop(), and rb_szqueue_push().
Definition at line 617 of file thread_sync.c.
References FL_SET, GET_QUEUE_WAITERS, GET_SZQUEUE_WAITERS, QUEUE_CLOSED, queue_closed_p(), queue_num_waiting(), szqueue_num_waiting_producer(), and wakeup_all_threads().
Referenced by rb_queue_close(), and rb_szqueue_close().
Definition at line 781 of file thread_sync.c.
References assert, GET_QUEUE_QUE, GET_QUEUE_WAITERS, Qfalse, queue_closed_p(), queue_closed_result(), queue_delete_from_waiting(), queue_length(), queue_sleep(), rb_ary_push(), rb_ary_shift(), rb_ensure(), rb_eThreadError, rb_raise(), rb_thread_current(), waiting_delete::th, and waiting_delete::waiting.
Referenced by rb_queue_pop(), and szqueue_do_pop().
Definition at line 685 of file thread_sync.c.
References GET_QUEUE_QUE, GET_QUEUE_WAITERS, queue_closed_p(), raise_closed_queue_error(), rb_ary_push(), and wakeup_first_thread().
Referenced by rb_queue_push(), and rb_szqueue_push().
|
static |
Definition at line 577 of file thread_sync.c.
References GET_QUEUE_QUE, and RARRAY_LEN.
Referenced by queue_closed_result(), queue_do_pop(), rb_queue_empty_p(), rb_queue_length(), rb_szqueue_push(), and szqueue_do_pop().
|
static |
Definition at line 584 of file thread_sync.c.
References GET_QUEUE_WAITERS, and RARRAY_LEN.
Referenced by queue_do_close(), rb_queue_num_waiting(), and rb_szqueue_num_waiting().
Definition at line 807 of file thread_sync.c.
References rb_check_arity, and RTEST.
Referenced by rb_queue_pop(), and rb_szqueue_pop().
Definition at line 774 of file thread_sync.c.
References Qnil, and rb_thread_sleep_deadly_allow_spurious_wakeup().
Referenced by queue_do_pop(), and rb_szqueue_push().
|
static |
Definition at line 604 of file thread_sync.c.
References rb_eClosedQueueError, and rb_raise().
Referenced by queue_do_push(), and rb_szqueue_push().
Definition at line 1216 of file thread_sync.c.
References GET_CONDVAR_WAITERS, and wakeup_all_threads().
Referenced by Init_thread_sync().
Definition at line 1143 of file thread_sync.c.
References ary_buf_new(), CONDVAR_WAITERS, and RSTRUCT_SET.
Referenced by Init_thread_sync().
Definition at line 1203 of file thread_sync.c.
References GET_CONDVAR_WAITERS, and wakeup_first_thread().
Referenced by Init_thread_sync().
Definition at line 1180 of file thread_sync.c.
References delete_current_thread(), do_sleep(), GET_CONDVAR_WAITERS, sleep_call::mutex, rb_ary_push(), rb_ensure(), rb_scan_args(), rb_thread_current(), and sleep_call::timeout.
Referenced by Init_thread_sync().
void rb_mutex_allow_trap | ( | VALUE | self, |
int | val | ||
) |
Definition at line 511 of file thread_sync.c.
References rb_mutex_struct::allow_trap, GetMutexPtr, and val.
Referenced by io_binwrite().
Definition at line 241 of file thread_sync.c.
References rb_mutex_struct::allow_trap, FALSE, GET_THREAD, GetMutexPtr, GVL_UNLOCK_BEGIN, GVL_UNLOCK_END, rb_thread_struct::interrupt_mask, rb_mutex_struct::lock, lock_func(), lock_interrupt(), rb_thread_struct::locking_mutex, mutex_locked(), NULL, Qfalse, rb_check_deadlock(), rb_eThreadError, rb_mutex_trylock(), rb_raise(), reset_unblock_function(), RUBY_VM_CHECK_INTS_BLOCKING, set_unblock_function(), rb_vm_struct::sleeper, rb_thread_struct::status, rb_mutex_struct::th, THREAD_STOPPED_FOREVER, TRAP_INTERRUPT_MASK, rb_thread_struct::vm, and vm_living_thread_num().
Referenced by Init_thread_sync(), rb_mutex_sleep(), rb_mutex_synchronize(), rb_thread_shield_new(), and rb_thread_shield_wait().
Definition at line 130 of file thread_sync.c.
References GetMutexPtr, Qfalse, Qtrue, and rb_mutex_struct::th.
Referenced by Init_thread_sync().
VALUE rb_mutex_new | ( | void | ) |
Definition at line 118 of file thread_sync.c.
References mutex_alloc(), and rb_cMutex.
Referenced by io_binwrite().
Definition at line 316 of file thread_sync.c.
References GET_THREAD, GetMutexPtr, Qfalse, Qtrue, and rb_mutex_struct::th.
Referenced by finish_writeconv(), Init_thread_sync(), and io_flush_buffer().
Definition at line 436 of file thread_sync.c.
References INT2FIX, NIL_P, Qnil, rb_ensure(), rb_mutex_lock(), rb_mutex_sleep_forever(), rb_mutex_unlock(), rb_mutex_wait_for(), and rb_time_interval().
Referenced by mutex_sleep().
Definition at line 421 of file thread_sync.c.
References Qnil, and rb_thread_sleep_deadly_allow_spurious_wakeup().
Referenced by rb_mutex_sleep().
Definition at line 488 of file thread_sync.c.
References func, rb_ensure(), rb_mutex_lock(), and rb_mutex_unlock().
Referenced by fptr_finalize_flush(), io_binwrite(), io_flush_buffer(), and rb_mutex_synchronize_m().
Definition at line 502 of file thread_sync.c.
References Qundef, rb_block_given_p(), rb_eThreadError, rb_mutex_synchronize(), rb_raise(), and rb_yield().
Referenced by Init_thread_sync().
Definition at line 157 of file thread_sync.c.
References GET_THREAD, GetMutexPtr, rb_mutex_struct::lock, mutex_locked(), Qfalse, Qtrue, and rb_mutex_struct::th.
Referenced by Init_thread_sync(), and rb_mutex_lock().
Definition at line 371 of file thread_sync.c.
References err, GET_THREAD, GetMutexPtr, rb_thread_struct::keeping_mutexes, rb_thread_struct::locking_mutex, rb_mutex_struct::next_mutex, NULL, Qfalse, rb_eThreadError, rb_mutex_unlock_th(), rb_raise(), and rb_mutex_struct::th.
Referenced by Init_thread_sync(), rb_mutex_sleep(), rb_mutex_synchronize(), rb_thread_shield_destroy(), rb_thread_shield_release(), and rb_thread_shield_wait().
|
static |
Definition at line 331 of file thread_sync.c.
References rb_mutex_struct::cond, 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_threadptr_unlock_all_locking_mutexes().
Definition at line 428 of file thread_sync.c.
References GET_THREAD, Qnil, and sleep_timeval().
Referenced by rb_mutex_sleep().
Definition at line 83 of file thread_sync.c.
References Qfalse, Qtrue, and rb_typeddata_is_kind_of().
Referenced by rb_objspace_call_finalizer().
Definition at line 858 of file thread_sync.c.
References GET_QUEUE_QUE, and rb_ary_clear().
Referenced by Init_thread_sync().
Definition at line 727 of file thread_sync.c.
References FALSE, and queue_do_close().
Referenced by Init_thread_sync().
Definition at line 740 of file thread_sync.c.
References Qfalse, Qtrue, and queue_closed_p().
Referenced by Init_thread_sync().
Definition at line 846 of file thread_sync.c.
References Qfalse, Qtrue, and queue_length().
Referenced by Init_thread_sync().
Definition at line 677 of file thread_sync.c.
References ary_buf_new(), QUEUE_QUE, QUEUE_WAITERS, and RSTRUCT_SET.
Referenced by Init_thread_sync().
Definition at line 874 of file thread_sync.c.
References len, queue_length(), and ULONG2NUM.
Referenced by Init_thread_sync().
Definition at line 887 of file thread_sync.c.
References len, queue_num_waiting(), and ULONG2NUM.
Referenced by Init_thread_sync().
Definition at line 832 of file thread_sync.c.
References queue_do_pop(), and queue_pop_should_block().
Referenced by Init_thread_sync().
Definition at line 756 of file thread_sync.c.
References queue_do_push().
Referenced by Init_thread_sync().
Definition at line 1077 of file thread_sync.c.
References GET_QUEUE_QUE, GET_SZQUEUE_WAITERS, rb_ary_clear(), and wakeup_all_threads().
Referenced by Init_thread_sync().
Definition at line 940 of file thread_sync.c.
References queue_do_close(), and TRUE.
Referenced by Init_thread_sync().
Definition at line 910 of file thread_sync.c.
References ary_buf_new(), max(), NUM2LONG, QUEUE_QUE, QUEUE_WAITERS, rb_eArgError, rb_raise(), RSTRUCT_SET, SZQUEUE_MAX, and SZQUEUE_WAITERS.
Referenced by Init_thread_sync().
Definition at line 952 of file thread_sync.c.
References GET_SZQUEUE_MAX.
Referenced by Init_thread_sync().
Definition at line 965 of file thread_sync.c.
References diff(), GET_SZQUEUE_ULONGMAX, GET_SZQUEUE_WAITERS, max(), NIL_P, NUM2LONG, rb_ary_shift(), rb_eArgError, rb_raise(), rb_thread_wakeup_alive(), RSTRUCT_SET, and SZQUEUE_MAX.
Referenced by Init_thread_sync().
Definition at line 1091 of file thread_sync.c.
References len, queue_num_waiting(), szqueue_num_waiting_producer(), and ULONG2NUM.
Referenced by Init_thread_sync().
Definition at line 1064 of file thread_sync.c.
References queue_pop_should_block(), and szqueue_do_pop().
Referenced by Init_thread_sync().
Definition at line 1009 of file thread_sync.c.
References GET_SZQUEUE_ULONGMAX, GET_SZQUEUE_WAITERS, Qfalse, queue_closed_p(), queue_delete_from_waiting(), queue_do_push(), queue_length(), queue_sleep(), raise_closed_queue_error(), rb_ary_push(), rb_ensure(), rb_eThreadError, rb_raise(), rb_thread_current(), szqueue_push_should_block(), waiting_delete::th, and waiting_delete::waiting.
Referenced by Init_thread_sync().
Definition at line 1038 of file thread_sync.c.
References GET_SZQUEUE_ULONGMAX, GET_SZQUEUE_WAITERS, queue_do_pop(), queue_length(), and wakeup_first_thread().
Referenced by rb_szqueue_pop().
|
static |
Definition at line 591 of file thread_sync.c.
References GET_SZQUEUE_WAITERS, and RARRAY_LEN.
Referenced by queue_do_close(), and rb_szqueue_num_waiting().
Definition at line 984 of file thread_sync.c.
References rb_check_arity, and RTEST.
Referenced by rb_szqueue_push().
Definition at line 1224 of file thread_sync.c.
References PRIsVALUE, rb_eTypeError, rb_obj_class(), rb_raise(), and UNREACHABLE.
Referenced by Init_thread_sync().
|
static |
Definition at line 564 of file thread_sync.c.
References RARRAY_AREF, RARRAY_LEN, rb_ary_clear(), and rb_thread_wakeup_alive().
Referenced by queue_do_close(), rb_condvar_broadcast(), and rb_szqueue_clear().
|
static |
Definition at line 554 of file thread_sync.c.
References NIL_P, rb_ary_shift(), rb_thread_wakeup_alive(), and RTEST.
Referenced by queue_do_push(), rb_condvar_signal(), and szqueue_do_pop().
|
static |
Definition at line 1154 of file thread_sync.c.
|
static |
Definition at line 76 of file thread_sync.c.
|
static |
Definition at line 231 of file thread_sync.c.
Referenced by rb_check_deadlock().
|
static |
Definition at line 3 of file thread_sync.c.
Referenced by Init_thread_sync().
|
static |
Definition at line 3 of file thread_sync.c.
Referenced by Init_thread_sync(), and rb_mutex_new().
|
static |
Definition at line 3 of file thread_sync.c.
Referenced by Init_thread_sync().
|
static |
Definition at line 3 of file thread_sync.c.
Referenced by Init_thread_sync().
|
static |
Definition at line 4 of file thread_sync.c.
Referenced by Init_thread_sync(), and raise_closed_queue_error().