diff options
Diffstat (limited to 'thread_win32.c')
| -rw-r--r-- | thread_win32.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/thread_win32.c b/thread_win32.c index 46780d8ff..0befbff4a 100644 --- a/thread_win32.c +++ b/thread_win32.c @@ -455,7 +455,6 @@ static unsigned long _stdcall thread_start_func_1(void *th_ptr) { rb_thread_t *th = th_ptr; - VALUE stack_start; volatile HANDLE thread_id = th->thread_id; native_thread_init_stack(th); @@ -464,7 +463,8 @@ thread_start_func_1(void *th_ptr) /* run */ thread_debug("thread created (th: %p, thid: %p, event: %p)\n", th, th->thread_id, th->native_thread_data.interrupt_event); - thread_start_func_2(th, &stack_start, 0); + + thread_start_func_2(th, th->machine_stack_start, rb_ia64_bsp()); w32_close_handle(thread_id); thread_debug("thread deleted (th: %p)\n", th); @@ -531,27 +531,42 @@ ubf_handle(void *ptr) } static HANDLE timer_thread_id = 0; +static HANDLE timer_thread_lock; static unsigned long _stdcall timer_thread_func(void *dummy) { thread_debug("timer_thread\n"); - while (system_working) { - Sleep(WIN32_WAIT_TIMEOUT); + while (WaitForSingleObject(timer_thread_lock, WIN32_WAIT_TIMEOUT) == + WAIT_TIMEOUT) { timer_thread_function(dummy); } thread_debug("timer killed\n"); return 0; } -void +static void rb_thread_create_timer_thread(void) { if (timer_thread_id == 0) { + if (!timer_thread_lock) { + timer_thread_lock = CreateEvent(0, TRUE, FALSE, 0); + } timer_thread_id = w32_create_thread(1024 + (THREAD_DEBUG ? BUFSIZ : 0), - timer_thread_func, GET_VM()); + timer_thread_func, 0); w32_resume_thread(timer_thread_id); } } +static int +native_stop_timer_thread(void) +{ + int stopped = --system_working <= 0; + if (stopped) { + CloseHandle(timer_thread_lock); + timer_thread_lock = 0; + } + return stopped; +} + #endif /* THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION */ |
