#include <ruby.h>Go to the source code of this file.
Data Structures | |
| struct | sleep_call |
| struct | waiting_delete |
Defines | |
| #define | GET_CONDVAR_WAITERS(cv) get_array((cv), CONDVAR_WAITERS) |
| #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 | UNDER_THREAD 1 |
| #define | ALIAS_GLOBAL_CONST(name) |
| #define | OUTER rb_cThread |
Enumerations | |
| enum | { CONDVAR_WAITERS = 0 } |
| enum | { QUEUE_QUE = 0, QUEUE_WAITERS = 1, SZQUEUE_WAITERS = 2, SZQUEUE_MAX = 3 } |
Functions | |
| static VALUE | get_array (VALUE obj, int idx) |
| static VALUE | ary_buf_new (void) |
| static void | wakeup_first_thread (VALUE list) |
| static void | wakeup_all_threads (VALUE list) |
| static VALUE | rb_condvar_initialize (VALUE self) |
| static VALUE | do_sleep (VALUE args) |
| static VALUE | delete_current_thread (VALUE ary) |
| static VALUE | rb_condvar_wait (int argc, VALUE *argv, VALUE self) |
| static VALUE | rb_condvar_signal (VALUE self) |
| static VALUE | rb_condvar_broadcast (VALUE self) |
| static VALUE | rb_queue_initialize (VALUE self) |
| static VALUE | queue_do_push (VALUE self, VALUE obj) |
| static VALUE | rb_queue_push (VALUE self, VALUE obj) |
| static unsigned long | queue_length (VALUE self) |
| static unsigned long | queue_num_waiting (VALUE self) |
| static VALUE | queue_delete_from_waiting (struct waiting_delete *p) |
| static VALUE | queue_sleep (VALUE arg) |
| static VALUE | queue_do_pop (VALUE self, VALUE should_block) |
| static VALUE | queue_pop_should_block (int argc, VALUE *argv) |
| static VALUE | rb_queue_pop (int argc, VALUE *argv, VALUE self) |
| static VALUE | rb_queue_empty_p (VALUE self) |
| static VALUE | rb_queue_clear (VALUE self) |
| static VALUE | rb_queue_length (VALUE self) |
| static VALUE | rb_queue_num_waiting (VALUE self) |
| static VALUE | rb_szqueue_initialize (VALUE self, VALUE vmax) |
| static VALUE | rb_szqueue_max_get (VALUE self) |
| static VALUE | rb_szqueue_max_set (VALUE self, VALUE vmax) |
| static VALUE | rb_szqueue_push (VALUE self, VALUE obj) |
| static VALUE | szqueue_do_pop (VALUE self, VALUE should_block) |
| static VALUE | rb_szqueue_pop (int argc, VALUE *argv, VALUE self) |
| static VALUE | rb_szqueue_clear (VALUE self) |
| static VALUE | rb_szqueue_num_waiting (VALUE self) |
| static VALUE | undumpable (VALUE obj) |
| void | Init_thread (void) |
Variables | |
| static ID | id_sleep |
| #define ALIAS_GLOBAL_CONST | ( | name | ) |
do { \ ID id = rb_intern_const(#name); \ if (!rb_const_defined_at(rb_cObject, id)) { \ rb_const_set(rb_cObject, id, rb_c##name); \ } \ } while (0)
Referenced by Init_thread().
Definition at line 14 of file thread.c.
Referenced by rb_condvar_broadcast(), rb_condvar_signal(), and rb_condvar_wait().
| #define GET_QUEUE_QUE | ( | q | ) | get_array((q), QUEUE_QUE) |
Definition at line 16 of file thread.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 17 of file thread.c.
Referenced by queue_do_pop(), queue_do_push(), and queue_num_waiting().
| #define GET_SZQUEUE_MAX | ( | q | ) | RSTRUCT_GET((q), SZQUEUE_MAX) |
Definition at line 19 of file thread.c.
Referenced by rb_szqueue_max_get().
| #define GET_SZQUEUE_ULONGMAX | ( | q | ) | NUM2ULONG(GET_SZQUEUE_MAX(q)) |
Definition at line 20 of file thread.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 18 of file thread.c.
Referenced by rb_szqueue_clear(), rb_szqueue_max_set(), rb_szqueue_num_waiting(), rb_szqueue_push(), and szqueue_do_pop().
| #define OUTER rb_cThread |
Referenced by Init_thread().
| anonymous enum |
| static VALUE ary_buf_new | ( | void | ) | [static] |
Definition at line 33 of file thread.c.
References rb_ary_tmp_new().
Referenced by rb_condvar_initialize(), rb_queue_initialize(), and rb_szqueue_initialize().
| static VALUE delete_current_thread | ( | VALUE | ary | ) | [static] |
Definition at line 119 of file thread.c.
References rb_ary_delete(), and rb_thread_current().
Referenced by rb_condvar_wait().
| static VALUE do_sleep | ( | VALUE | args | ) | [static] |
Definition at line 112 of file thread.c.
References id_sleep, sleep_call::mutex, rb_funcall2, and sleep_call::timeout.
Referenced by rb_condvar_wait().
| static VALUE get_array | ( | VALUE | obj, | |
| int | idx | |||
| ) | [static] |
Definition at line 23 of file thread.c.
References PRIsVALUE, rb_eTypeError, rb_raise(), RB_TYPE_P, RSTRUCT_GET, and T_ARRAY.
| void Init_thread | ( | void | ) |
Definition at line 555 of file thread.c.
References ALIAS_GLOBAL_CONST, id_sleep, NULL, OUTER, rb_cObject, rb_condvar_broadcast(), rb_condvar_initialize(), rb_condvar_signal(), rb_condvar_wait(), rb_define_alias(), rb_define_class(), rb_define_method(), rb_intern, rb_provide(), rb_queue_clear(), 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_initialize(), rb_szqueue_max_get(), rb_szqueue_max_set(), rb_szqueue_num_waiting(), rb_szqueue_pop(), rb_szqueue_push(), rb_undef_method(), and undumpable().
| static VALUE queue_delete_from_waiting | ( | struct waiting_delete * | p | ) | [static] |
Definition at line 261 of file thread.c.
References Qnil, rb_ary_delete(), waiting_delete::th, and waiting_delete::waiting.
Referenced by queue_do_pop(), and rb_szqueue_push().
| static VALUE queue_do_pop | ( | VALUE | self, | |
| VALUE | should_block | |||
| ) | [static] |
Definition at line 275 of file thread.c.
References GET_QUEUE_QUE, GET_QUEUE_WAITERS, 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().
| static VALUE queue_do_push | ( | VALUE | self, | |
| VALUE | obj | |||
| ) | [static] |
Definition at line 220 of file thread.c.
References GET_QUEUE_QUE, GET_QUEUE_WAITERS, rb_ary_push(), and wakeup_first_thread().
Referenced by rb_queue_push(), and rb_szqueue_push().
| static unsigned long queue_length | ( | VALUE | self | ) | [static] |
Definition at line 244 of file thread.c.
References GET_QUEUE_QUE, and RARRAY_LEN.
Referenced by queue_do_pop(), rb_queue_empty_p(), rb_queue_length(), rb_szqueue_push(), and szqueue_do_pop().
| static unsigned long queue_num_waiting | ( | VALUE | self | ) | [static] |
Definition at line 250 of file thread.c.
References GET_QUEUE_WAITERS, and RARRAY_LEN.
Referenced by rb_queue_num_waiting(), and rb_szqueue_num_waiting().
| static VALUE queue_pop_should_block | ( | int | argc, | |
| VALUE * | argv | |||
| ) | [static] |
Definition at line 293 of file thread.c.
References Qfalse, Qtrue, rb_eArgError, rb_raise(), and RTEST.
Referenced by rb_queue_pop(), and rb_szqueue_pop().
| static VALUE queue_sleep | ( | VALUE | arg | ) | [static] |
Definition at line 268 of file thread.c.
References Qnil, and rb_thread_sleep_deadly().
Referenced by queue_do_pop().
| static VALUE rb_condvar_broadcast | ( | VALUE | self | ) | [static] |
Definition at line 171 of file thread.c.
References GET_CONDVAR_WAITERS, and wakeup_all_threads().
Referenced by Init_thread().
| static VALUE rb_condvar_initialize | ( | VALUE | self | ) | [static] |
Definition at line 98 of file thread.c.
References ary_buf_new(), CONDVAR_WAITERS, and RSTRUCT_SET.
Referenced by Init_thread().
| static VALUE rb_condvar_signal | ( | VALUE | self | ) | [static] |
Definition at line 158 of file thread.c.
References GET_CONDVAR_WAITERS, and wakeup_first_thread().
Referenced by Init_thread().
| static VALUE rb_condvar_wait | ( | int | argc, | |
| VALUE * | argv, | |||
| VALUE | self | |||
| ) | [static] |
Definition at line 135 of file thread.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().
| static VALUE rb_queue_clear | ( | VALUE | self | ) | [static] |
Definition at line 349 of file thread.c.
References GET_QUEUE_QUE, and rb_ary_clear().
Referenced by Init_thread().
| static VALUE rb_queue_empty_p | ( | VALUE | self | ) | [static] |
Definition at line 337 of file thread.c.
References Qfalse, Qtrue, and queue_length().
Referenced by Init_thread().
| static VALUE rb_queue_initialize | ( | VALUE | self | ) | [static] |
Definition at line 212 of file thread.c.
References ary_buf_new(), QUEUE_QUE, QUEUE_WAITERS, and RSTRUCT_SET.
Referenced by Init_thread().
| static VALUE rb_queue_length | ( | VALUE | self | ) | [static] |
Definition at line 365 of file thread.c.
References queue_length(), and ULONG2NUM.
Referenced by Init_thread().
| static VALUE rb_queue_num_waiting | ( | VALUE | self | ) | [static] |
Definition at line 378 of file thread.c.
References queue_num_waiting(), and ULONG2NUM.
Referenced by Init_thread().
| static VALUE rb_queue_pop | ( | int | argc, | |
| VALUE * | argv, | |||
| VALUE | self | |||
| ) | [static] |
Definition at line 323 of file thread.c.
References queue_do_pop(), and queue_pop_should_block().
Referenced by Init_thread().
| static VALUE rb_queue_push | ( | VALUE | self, | |
| VALUE | obj | |||
| ) | [static] |
| static VALUE rb_szqueue_clear | ( | VALUE | self | ) | [static] |
Definition at line 522 of file thread.c.
References GET_QUEUE_QUE, GET_SZQUEUE_WAITERS, rb_ary_clear(), and wakeup_all_threads().
Referenced by Init_thread().
| static VALUE rb_szqueue_initialize | ( | VALUE | self, | |
| VALUE | vmax | |||
| ) | [static] |
Definition at line 401 of file thread.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().
| static VALUE rb_szqueue_max_get | ( | VALUE | self | ) | [static] |
| static VALUE rb_szqueue_max_set | ( | VALUE | self, | |
| VALUE | vmax | |||
| ) | [static] |
Definition at line 438 of file thread.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, SZQUEUE_MAX, and t().
Referenced by Init_thread().
| static VALUE rb_szqueue_num_waiting | ( | VALUE | self | ) | [static] |
Definition at line 536 of file thread.c.
References GET_SZQUEUE_WAITERS, queue_num_waiting(), RARRAY_LEN, and ULONG2NUM.
Referenced by Init_thread().
| static VALUE rb_szqueue_pop | ( | int | argc, | |
| VALUE * | argv, | |||
| VALUE | self | |||
| ) | [static] |
Definition at line 509 of file thread.c.
References queue_pop_should_block(), and szqueue_do_pop().
Referenced by Init_thread().
| static VALUE rb_szqueue_push | ( | VALUE | self, | |
| VALUE | obj | |||
| ) | [static] |
Definition at line 469 of file thread.c.
References GET_SZQUEUE_ULONGMAX, GET_SZQUEUE_WAITERS, queue_delete_from_waiting(), queue_do_push(), queue_length(), rb_ary_push(), rb_ensure(), rb_thread_current(), rb_thread_sleep_deadly(), waiting_delete::th, and waiting_delete::waiting.
Referenced by Init_thread().
| static VALUE szqueue_do_pop | ( | VALUE | self, | |
| VALUE | should_block | |||
| ) | [static] |
Definition at line 483 of file thread.c.
References GET_SZQUEUE_ULONGMAX, GET_SZQUEUE_WAITERS, queue_do_pop(), queue_length(), and wakeup_first_thread().
Referenced by rb_szqueue_pop().
| static VALUE undumpable | ( | VALUE | obj | ) | [static] |
Definition at line 548 of file thread.c.
References PRIsVALUE, rb_eTypeError, rb_obj_class(), rb_raise(), and UNREACHABLE.
Referenced by Init_thread().
| static void wakeup_all_threads | ( | VALUE | list | ) | [static] |
Definition at line 49 of file thread.c.
References RARRAY_AREF, RARRAY_LEN, rb_ary_clear(), and rb_thread_wakeup_alive().
Referenced by rb_condvar_broadcast(), and rb_szqueue_clear().
| static void wakeup_first_thread | ( | VALUE | list | ) | [static] |
Definition at line 39 of file thread.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().
ID id_sleep [static] |
Definition at line 109 of file thread.c.
Referenced by do_sleep(), and Init_thread().
1.6.1