#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_t * | ruby_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 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, | |||
| v | ) | (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 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.
| static int __cond_timedwait | ( | rb_thread_cond_t * | cond, | |
| rb_thread_lock_t * | mutex, | |||
| unsigned long | msec | |||
| ) | [static] |
Definition at line 451 of file thread_win32.c.
References ETIMEDOUT, cond_event_entry::event, FALSE, native_mutex_lock(), native_mutex_unlock(), cond_event_entry::next, cond_event_entry::prev, rb_bug(), and w32_close_handle().
Referenced by native_cond_timedwait(), and native_cond_wait().
| static unsigned long abs_timespec_to_timeout_ms | ( | struct timespec * | ts | ) | [static] |
Definition at line 488 of file thread_win32.c.
References gettimeofday(), NULL, rb_w32_time_subtract(), timespec::tv_nsec, timespec::tv_sec, timeval::tv_sec, and timeval::tv_usec.
Referenced by native_cond_timedwait().
| static void gvl_acquire | ( | rb_vm_t * | vm, | |
| rb_thread_t * | th | |||
| ) | [static] |
Definition at line 96 of file thread_win32.c.
References rb_vm_struct::gvl, GVL_DEBUG, rb_global_vm_lock_struct::lock, and w32_mutex_lock().
Referenced by gvl_yield(), and w32_wait_events().
| 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] |
Definition at line 124 of file thread_win32.c.
References rb_vm_struct::gvl, GVL_DEBUG, rb_global_vm_lock_struct::lock, and w32_mutex_create().
| 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] |
Definition at line 109 of file thread_win32.c.
References gvl_acquire(), gvl_release(), native_thread_yield, and rb_thread_struct::vm.
| void Init_native_thread | ( | void | ) |
Definition at line 150 of file thread_win32.c.
References FALSE, GET_THREAD, native_thread_data_struct::interrupt_event, rb_thread_struct::native_thread_data, ruby_native_thread_key, ruby_thread_set_native(), thread_debug, rb_thread_struct::thread_id, and TRUE.
| static void native_cond_broadcast | ( | rb_thread_cond_t * | cond | ) | [static] |
Definition at line 429 of file thread_win32.c.
References cond_event_entry::event, cond_event_entry::next, rb_thread_cond_struct::next, cond_event_entry::prev, and prev.
| 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] |
Definition at line 410 of file thread_win32.c.
References cond_event_entry::event, cond_event_entry::next, rb_thread_cond_struct::next, cond_event_entry::prev, and prev.
| 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] |
Definition at line 528 of file thread_win32.c.
References gettimeofday(), rb_sys_fail, TIMET_MAX, timespec::tv_nsec, timeval::tv_sec, timespec::tv_sec, and timeval::tv_usec.
| 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] |
Definition at line 302 of file thread_win32.c.
References rb_unblock_callback::arg, rb_unblock_callback::func, GVL_UNLOCK_BEGIN, GVL_UNLOCK_END, rb_thread_struct::interrupt_lock, native_mutex_lock(), native_mutex_unlock(), RUBY_VM_INTERRUPTED, thread_debug, timeval::tv_sec, timeval::tv_usec, ubf_handle(), rb_thread_struct::unblock, and w32_wait_events().
| 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] |
Definition at line 629 of file thread_win32.c.
References native_thread_data_struct::interrupt_event, rb_thread_struct::native_thread_data, PRIdSIZE, thread_debug, THREAD_DEBUG, thread_errno, rb_thread_struct::thread_id, thread_start_func_1(), w32_create_thread(), and w32_resume_thread().
| static void native_thread_destroy | ( | rb_thread_t * | th | ) | [static] |
Definition at line 601 of file thread_win32.c.
References InterlockedExchangePointer, native_thread_data_struct::interrupt_event, rb_thread_struct::native_thread_data, thread_debug, rb_thread_struct::thread_id, and w32_close_handle().
| static void native_thread_init_stack | ( | rb_thread_t * | th | ) | [static] |
Definition at line 579 of file thread_win32.c.
References CHECK_ERR, rb_thread_struct::machine_stack_maxsize, rb_thread_struct::machine_stack_start, and size.
Referenced by thread_start_func_1().
| 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] |
Definition at line 735 of file thread_win32.c.
References FALSE, THREAD_DEBUG, timer_thread_func(), TRUE, w32_create_thread(), and w32_resume_thread().
| 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 * | ||||
| ) |
Definition at line 2606 of file win32.c.
References compare(), copy_fd(), do_select(), errno, extract_fd(), gettimeofday(), if(), is_console(), is_invalid_handle(), is_not_socket(), is_pipe(), is_readable_console(), is_readable_pipe(), NULL, rb_fd_init, rb_fd_term, rb_w32_check_interrupt(), rb_w32_time_subtract(), StartSockets(), timeval::tv_sec, and timeval::tv_usec.
Referenced by native_fd_select(), and rb_w32_select().
| 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 | |||
| ) |
Definition at line 232 of file thread_win32.c.
References GET_THREAD, and w32_wait_events().
Referenced by finish_overlapped_socket(), poll_child_status(), rb_w32_asynchronize(), rb_w32_read(), rb_w32_wait_events(), rb_w32_write(), and waitpid().
| 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] |
Definition at line 609 of file thread_win32.c.
References FALSE, native_thread_data_struct::interrupt_event, rb_thread_struct::machine_stack_start, rb_thread_struct::native_thread_data, native_thread_init_stack(), thread_debug, rb_thread_struct::thread_id, thread_start_func_2, TRUE, and w32_close_handle().
Referenced by native_thread_create().
| 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] |
Definition at line 705 of file thread_win32.c.
References native_thread_data_struct::interrupt_event, rb_thread_struct::native_thread_data, thread_debug, and w32_set_event().
Referenced by native_sleep(), rb_w32_Sleep(), and rb_w32_wait_events().
| static void w32_close_handle | ( | HANDLE | handle | ) | [static] |
Definition at line 248 of file thread_win32.c.
References w32_error().
Referenced by __cond_timedwait(), native_mutex_destroy(), native_thread_destroy(), and thread_start_func_1().
| 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] |
Definition at line 185 of file thread_win32.c.
References ALLOCA_N, errno, FALSE, gvl_acquire(), gvl_release(), native_thread_data_struct::interrupt_event, rb_thread_struct::native_thread_data, RUBY_VM_INTERRUPTED, THREAD_DEBUG, thread_debug, rb_thread_struct::vm, w32_reset_event(), and w32_set_event().
Referenced by native_mutex_trylock(), native_sleep(), native_thread_join(), rb_w32_check_interrupt(), rb_w32_sleep(), rb_w32_wait_events_blocking(), and w32_mutex_lock().
volatile DWORD ruby_native_thread_key = TLS_OUT_OF_INDEXES [static] |
Definition at line 24 of file thread_win32.c.
Referenced by Init_native_thread(), ruby_thread_from_native(), and ruby_thread_set_native().
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.
1.6.1