thread_win32.c File Reference

#include <process.h>

Go to the source code of this file.

Data Structures

struct  cond_event_entry

Defines

#define TIME_QUANTUM_USEC   (100 * 1000)
#define RB_CONDATTR_CLOCK_MONOTONIC   1
#define native_thread_yield()   Sleep(0)
#define remove_signal_thread_list(th)
#define GVL_DEBUG   0
#define ubf_select   ubf_handle
#define start_thread   CreateThread
#define thread_errno   rb_w32_map_errno(GetLastError())
#define TIMET_MAX   (~(time_t)0 <= 0 ? (time_t)((~(unsigned_time_t)0) >> 1) : (time_t)(~(unsigned_time_t)0))
#define CHECK_ERR(expr)   {if (!(expr)) {rb_bug("err: %lu - %s", GetLastError(), #expr);}}
#define InterlockedExchangePointer(t, v)   (void *)InterlockedExchange((long *)(t), (long)(v))

Typedefs

typedef LPTHREAD_START_ROUTINE w32_thread_start_func
typedef unsigned long unsigned_time_t

Functions

static int w32_wait_events (HANDLE *events, int count, DWORD timeout, rb_thread_t *th)
static int native_mutex_lock (rb_thread_lock_t *lock)
static int native_mutex_unlock (rb_thread_lock_t *lock)
static void w32_error (const char *func)
static int w32_mutex_lock (HANDLE lock)
static HANDLE w32_mutex_create (void)
static void gvl_acquire (rb_vm_t *vm, rb_thread_t *th)
static void gvl_release (rb_vm_t *vm)
static void gvl_yield (rb_vm_t *vm, rb_thread_t *th)
static void gvl_atfork (rb_vm_t *vm)
static void gvl_init (rb_vm_t *vm)
static void gvl_destroy (rb_vm_t *vm)
static rb_thread_truby_thread_from_native (void)
static int ruby_thread_set_native (rb_thread_t *th)
void Init_native_thread (void)
static void w32_set_event (HANDLE handle)
static void w32_reset_event (HANDLE handle)
static void ubf_handle (void *ptr)
int rb_w32_wait_events_blocking (HANDLE *events, int num, DWORD timeout)
int rb_w32_wait_events (HANDLE *events, int num, DWORD timeout)
static void w32_close_handle (HANDLE handle)
static void w32_resume_thread (HANDLE handle)
static HANDLE w32_create_thread (DWORD stack_size, w32_thread_start_func func, void *val)
int rb_w32_sleep (unsigned long msec)
int WINAPI rb_w32_Sleep (unsigned long msec)
static void native_sleep (rb_thread_t *th, struct timeval *tv)
static int native_mutex_trylock (rb_thread_lock_t *lock)
static void native_mutex_initialize (rb_thread_lock_t *lock)
static void native_mutex_destroy (rb_thread_lock_t *lock)
static void native_cond_signal (rb_thread_cond_t *cond)
static void native_cond_broadcast (rb_thread_cond_t *cond)
static int __cond_timedwait (rb_thread_cond_t *cond, rb_thread_lock_t *mutex, unsigned long msec)
static int native_cond_wait (rb_thread_cond_t *cond, rb_thread_lock_t *mutex)
static unsigned long abs_timespec_to_timeout_ms (struct timespec *ts)
static int native_cond_timedwait (rb_thread_cond_t *cond, rb_thread_lock_t *mutex, struct timespec *ts)
static struct timespec native_cond_timeout (rb_thread_cond_t *cond, struct timespec timeout_rel)
static void native_cond_initialize (rb_thread_cond_t *cond, int flags)
static void native_cond_destroy (rb_thread_cond_t *cond)
void ruby_init_stack (volatile VALUE *addr)
static void native_thread_init_stack (rb_thread_t *th)
static void native_thread_destroy (rb_thread_t *th)
static unsigned long _stdcall thread_start_func_1 (void *th_ptr)
static int native_thread_create (rb_thread_t *th)
static void native_thread_join (HANDLE th)
int rb_w32_select_with_thread (int, fd_set *, fd_set *, fd_set *, struct timeval *, void *)
static int native_fd_select (int n, rb_fdset_t *readfds, rb_fdset_t *writefds, rb_fdset_t *exceptfds, struct timeval *timeout, rb_thread_t *th)
int rb_w32_check_interrupt (rb_thread_t *th)
static unsigned long _stdcall timer_thread_func (void *dummy)
void rb_thread_wakeup_timer_thread (void)
static void rb_thread_create_timer_thread (void)
static int native_stop_timer_thread (int close_anyway)
static void native_reset_timer_thread (void)
int rb_reserved_fd_p (int fd)

Variables

static volatile DWORD ruby_native_thread_key = TLS_OUT_OF_INDEXES
static HANDLE timer_thread_id = 0
static HANDLE timer_thread_lock

Define Documentation

#define CHECK_ERR ( expr   )     {if (!(expr)) {rb_bug("err: %lu - %s", GetLastError(), #expr);}}

Definition at line 575 of file thread_win32.c.

#define GVL_DEBUG   0

Definition at line 93 of file thread_win32.c.

Referenced by gvl_acquire(), gvl_destroy(), and gvl_init().

#define InterlockedExchangePointer ( t,
 )     (void *)InterlockedExchange((long *)(t), (long)(v))

Definition at line 597 of file thread_win32.c.

Referenced by native_thread_destroy().

 
#define native_thread_yield (  )     Sleep(0)

Definition at line 21 of file thread_win32.c.

#define RB_CONDATTR_CLOCK_MONOTONIC   1

Definition at line 17 of file thread_win32.c.

#define remove_signal_thread_list ( th   ) 

Definition at line 22 of file thread_win32.c.

Referenced by blocking_region_end().

#define start_thread   CreateThread

Definition at line 274 of file thread_win32.c.

Referenced by w32_create_thread().

#define thread_errno   rb_w32_map_errno(GetLastError())

Definition at line 275 of file thread_win32.c.

Referenced by native_thread_create().

#define TIME_QUANTUM_USEC   (100 * 1000)

Definition at line 16 of file thread_win32.c.

#define TIMET_MAX   (~(time_t)0 <= 0 ? (time_t)((~(unsigned_time_t)0) >> 1) : (time_t)(~(unsigned_time_t)0))

Definition at line 525 of file thread_win32.c.

#define ubf_select   ubf_handle

Definition at line 229 of file thread_win32.c.


Typedef Documentation

typedef unsigned long unsigned_time_t

Definition at line 516 of file thread_win32.c.

typedef LPTHREAD_START_ROUTINE w32_thread_start_func

Definition at line 276 of file thread_win32.c.


Function Documentation

static int __cond_timedwait ( rb_thread_cond_t cond,
rb_thread_lock_t mutex,
unsigned long  msec 
) [static]
static unsigned long abs_timespec_to_timeout_ms ( struct timespec ts  )  [static]
static void gvl_acquire ( rb_vm_t vm,
rb_thread_t th 
) [static]
static void gvl_atfork ( rb_vm_t vm  )  [static]

Definition at line 118 of file thread_win32.c.

References rb_bug().

static void gvl_destroy ( rb_vm_t vm  )  [static]

Definition at line 131 of file thread_win32.c.

References rb_vm_struct::gvl, GVL_DEBUG, and rb_global_vm_lock_struct::lock.

static void gvl_init ( rb_vm_t vm  )  [static]
static void gvl_release ( rb_vm_t vm  )  [static]

Definition at line 103 of file thread_win32.c.

References rb_vm_struct::gvl, and rb_global_vm_lock_struct::lock.

Referenced by gvl_yield(), and w32_wait_events().

static void gvl_yield ( rb_vm_t vm,
rb_thread_t th 
) [static]
void Init_native_thread ( void   ) 
static void native_cond_broadcast ( rb_thread_cond_t cond  )  [static]
static void native_cond_destroy ( rb_thread_cond_t cond  )  [static]

Definition at line 565 of file thread_win32.c.

static void native_cond_initialize ( rb_thread_cond_t cond,
int  flags 
) [static]

Definition at line 558 of file thread_win32.c.

References rb_thread_cond_struct::next, and rb_thread_cond_struct::prev.

static void native_cond_signal ( rb_thread_cond_t cond  )  [static]
static int native_cond_timedwait ( rb_thread_cond_t cond,
rb_thread_lock_t mutex,
struct timespec ts 
) [static]

Definition at line 504 of file thread_win32.c.

References __cond_timedwait(), abs_timespec_to_timeout_ms(), and ETIMEDOUT.

static struct timespec native_cond_timeout ( rb_thread_cond_t cond,
struct timespec  timeout_rel 
) [static, read]
static int native_cond_wait ( rb_thread_cond_t cond,
rb_thread_lock_t mutex 
) [static]

Definition at line 482 of file thread_win32.c.

References __cond_timedwait().

static int native_fd_select ( int  n,
rb_fdset_t readfds,
rb_fdset_t writefds,
rb_fdset_t exceptfds,
struct timeval timeout,
rb_thread_t th 
) [static]

Definition at line 679 of file thread_win32.c.

References NULL, rb_fd_ptr, rb_fd_resize, and rb_w32_select_with_thread().

Referenced by do_select().

static void native_mutex_destroy ( rb_thread_lock_t lock  )  [static]

Definition at line 394 of file thread_win32.c.

References w32_close_handle().

static void native_mutex_initialize ( rb_thread_lock_t lock  )  [static]

Definition at line 383 of file thread_win32.c.

References w32_mutex_create().

static int native_mutex_lock ( rb_thread_lock_t lock  )  [static]

Definition at line 340 of file thread_win32.c.

References w32_mutex_lock().

Referenced by __cond_timedwait(), and native_sleep().

static int native_mutex_trylock ( rb_thread_lock_t lock  )  [static]

Definition at line 363 of file thread_win32.c.

References result, thread_debug, TryEnterCriticalSection(), and w32_wait_events().

static int native_mutex_unlock ( rb_thread_lock_t lock  )  [static]

Definition at line 351 of file thread_win32.c.

References thread_debug.

Referenced by __cond_timedwait(), and native_sleep().

static void native_reset_timer_thread ( void   )  [static]

Definition at line 761 of file thread_win32.c.

static void native_sleep ( rb_thread_t th,
struct timeval tv 
) [static]
static int native_stop_timer_thread ( int  close_anyway  )  [static]

Definition at line 748 of file thread_win32.c.

References native_thread_join(), and system_working.

static int native_thread_create ( rb_thread_t th  )  [static]
static void native_thread_destroy ( rb_thread_t th  )  [static]
static void native_thread_init_stack ( rb_thread_t th  )  [static]
static void native_thread_join ( HANDLE  th  )  [static]

Definition at line 650 of file thread_win32.c.

References w32_wait_events().

Referenced by native_stop_timer_thread().

int rb_reserved_fd_p ( int  fd  ) 

Definition at line 783 of file thread_win32.c.

Referenced by rb_io_initialize().

static void rb_thread_create_timer_thread ( void   )  [static]
void rb_thread_wakeup_timer_thread ( void   ) 

Definition at line 729 of file thread_win32.c.

References errno, EWOULDBLOCK, rb_async_bug_errno(), result, TT_DEBUG, and WRITE_CONST.

int rb_w32_check_interrupt ( rb_thread_t th  ) 

Definition at line 699 of file thread_win32.c.

References w32_wait_events().

Referenced by rb_w32_select_with_thread().

int rb_w32_select_with_thread ( int  ,
fd_set *  ,
fd_set *  ,
fd_set *  ,
struct timeval ,
void *   
)
int WINAPI rb_w32_Sleep ( unsigned long  msec  ) 

Definition at line 292 of file thread_win32.c.

References BLOCKING_REGION, GET_THREAD, rb_w32_sleep(), and ubf_handle().

int rb_w32_sleep ( unsigned long  msec  ) 

Definition at line 286 of file thread_win32.c.

References GET_THREAD, and w32_wait_events().

Referenced by do_select(), and rb_w32_Sleep().

int rb_w32_wait_events ( HANDLE *  events,
int  num,
DWORD  timeout 
)

Definition at line 238 of file thread_win32.c.

References BLOCKING_REGION, GET_THREAD, rb_w32_wait_events_blocking(), and ubf_handle().

Referenced by catch_interrupt().

int rb_w32_wait_events_blocking ( HANDLE *  events,
int  num,
DWORD  timeout 
)
void ruby_init_stack ( volatile VALUE addr  ) 

Definition at line 571 of file thread_win32.c.

Referenced by Init_stack(), ruby_cleanup(), ruby_exec_node(), ruby_init(), and ruby_options().

static rb_thread_t* ruby_thread_from_native ( void   )  [static]

Definition at line 138 of file thread_win32.c.

References ruby_native_thread_key.

static int ruby_thread_set_native ( rb_thread_t th  )  [static]

Definition at line 144 of file thread_win32.c.

References ruby_native_thread_key.

Referenced by Init_native_thread().

static unsigned long _stdcall thread_start_func_1 ( void *  th_ptr  )  [static]
static unsigned long _stdcall timer_thread_func ( void *  dummy  )  [static]

Definition at line 717 of file thread_win32.c.

References thread_debug, TIME_QUANTUM_USEC, and timer_thread_function().

Referenced by rb_thread_create_timer_thread().

static void ubf_handle ( void *  ptr  )  [static]
static void w32_close_handle ( HANDLE  handle  )  [static]
static HANDLE w32_create_thread ( DWORD  stack_size,
w32_thread_start_func  func,
void *  val 
) [static]

Definition at line 280 of file thread_win32.c.

References start_thread.

Referenced by native_thread_create(), and rb_thread_create_timer_thread().

static void w32_error ( const char *  func  )  [static]

Definition at line 31 of file thread_win32.c.

References err, NULL, and rb_bug().

Referenced by w32_close_handle(), w32_mutex_create(), w32_reset_event(), w32_resume_thread(), and w32_set_event().

static HANDLE w32_mutex_create ( void   )  [static]

Definition at line 84 of file thread_win32.c.

References FALSE, NULL, and w32_error().

Referenced by gvl_init(), and native_mutex_initialize().

static int w32_mutex_lock ( HANDLE  lock  )  [static]

Definition at line 53 of file thread_win32.c.

References errno, rb_bug(), result, thread_debug, and w32_wait_events().

Referenced by gvl_acquire(), and native_mutex_lock().

static void w32_reset_event ( HANDLE  handle  )  [static]

Definition at line 177 of file thread_win32.c.

References w32_error().

Referenced by w32_wait_events().

static void w32_resume_thread ( HANDLE  handle  )  [static]

Definition at line 256 of file thread_win32.c.

References w32_error().

Referenced by native_thread_create(), and rb_thread_create_timer_thread().

static void w32_set_event ( HANDLE  handle  )  [static]

Definition at line 169 of file thread_win32.c.

References w32_error().

Referenced by ubf_handle(), and w32_wait_events().

static int w32_wait_events ( HANDLE *  events,
int  count,
DWORD  timeout,
rb_thread_t th 
) [static]

Variable Documentation

volatile DWORD ruby_native_thread_key = TLS_OUT_OF_INDEXES [static]
HANDLE timer_thread_id = 0 [static]

Definition at line 713 of file thread_win32.c.

HANDLE timer_thread_lock [static]

Definition at line 714 of file thread_win32.c.


Generated on 27 Nov 2014 for Ruby by  doxygen 1.6.1