Ruby  2.0.0p247(2013-06-27revision41674)
thread_pthread.h
Go to the documentation of this file.
00001 /**********************************************************************
00002 
00003   thread_pthread.h -
00004 
00005   $Author: nobu $
00006 
00007   Copyright (C) 2004-2007 Koichi Sasada
00008 
00009 **********************************************************************/
00010 
00011 #ifndef RUBY_THREAD_PTHREAD_H
00012 #define RUBY_THREAD_PTHREAD_H
00013 
00014 #include <pthread.h>
00015 #ifdef HAVE_PTHREAD_NP_H
00016 #include <pthread_np.h>
00017 #endif
00018 typedef pthread_t rb_thread_id_t;
00019 typedef pthread_mutex_t rb_thread_lock_t;
00020 
00021 typedef struct rb_thread_cond_struct {
00022     pthread_cond_t cond;
00023 #ifdef HAVE_CLOCKID_T
00024     clockid_t clockid;
00025 #endif
00026 } rb_thread_cond_t;
00027 
00028 typedef struct native_thread_data_struct {
00029     void *signal_thread_list;
00030     rb_thread_cond_t sleep_cond;
00031 } native_thread_data_t;
00032 
00033 #include <semaphore.h>
00034 
00035 #undef except
00036 #undef try
00037 #undef leave
00038 #undef finally
00039 
00040 typedef struct rb_global_vm_lock_struct {
00041     /* fast path */
00042     unsigned long acquired;
00043     pthread_mutex_t lock;
00044 
00045     /* slow path */
00046     volatile unsigned long waiting;
00047     rb_thread_cond_t cond;
00048 
00049     /* yield */
00050     rb_thread_cond_t switch_cond;
00051     rb_thread_cond_t switch_wait_cond;
00052     int need_yield;
00053     int wait_yield;
00054 } rb_global_vm_lock_t;
00055 
00056 #endif /* RUBY_THREAD_PTHREAD_H */
00057