ext/thread/thread.c File Reference

#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 Documentation

#define ALIAS_GLOBAL_CONST ( name   ) 
Value:
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().

#define GET_CONDVAR_WAITERS ( cv   )     get_array((cv), CONDVAR_WAITERS)

Definition at line 14 of file thread.c.

Referenced by rb_condvar_broadcast(), rb_condvar_signal(), and rb_condvar_wait().

#define GET_QUEUE_QUE (  )     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 (  )     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 (  )     RSTRUCT_GET((q), SZQUEUE_MAX)

Definition at line 19 of file thread.c.

Referenced by rb_szqueue_max_get().

#define GET_SZQUEUE_ULONGMAX (  )     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 (  )     get_array((q), SZQUEUE_WAITERS)
#define OUTER   rb_cThread

Referenced by Init_thread().

#define UNDER_THREAD   1

Definition at line 544 of file thread.c.


Enumeration Type Documentation

anonymous enum
Enumerator:
CONDVAR_WAITERS 

Definition at line 3 of file thread.c.

anonymous enum
Enumerator:
QUEUE_QUE 
QUEUE_WAITERS 
SZQUEUE_WAITERS 
SZQUEUE_MAX 

Definition at line 7 of file thread.c.


Function Documentation

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

Definition at line 238 of file thread.c.

References queue_do_push().

Referenced by Init_thread().

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]
static VALUE rb_szqueue_max_get ( VALUE  self  )  [static]

Definition at line 425 of file thread.c.

References GET_SZQUEUE_MAX.

Referenced by Init_thread().

static VALUE rb_szqueue_max_set ( VALUE  self,
VALUE  vmax 
) [static]
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]
static VALUE szqueue_do_pop ( VALUE  self,
VALUE  should_block 
) [static]
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().


Variable Documentation

ID id_sleep [static]

Definition at line 109 of file thread.c.

Referenced by do_sleep(), and Init_thread().


Generated on 18 May 2020 for Ruby by  doxygen 1.6.1