diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-08 20:24:55 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-08 20:24:55 +0000 |
commit | a9026242f2292cc7df06628652f4254c55c37e22 (patch) | |
tree | 958b2e49be9f42936803085f5ccadc41d75b2c49 /thread_win32.ci | |
parent | 990ae267cdc73f954a3fa0b43135f2bbec9f76e8 (diff) | |
download | ruby-a9026242f2292cc7df06628652f4254c55c37e22.tar.gz |
* thread.c, thread_pthread.ci, thread_win32.ci (thread_start_func_1):
move cleanup function to thread_start_func_2().
* thread.c, thread_pthread.ci, thread_win32.ci:
add more destruct functions.
(native_thread_destroy() and native_mutex_destroy())
* thread_pthread.ci, thread_pthread.h: make native_mutex_* functions
(check error, etc), it's not macro any more.
* thread_win32.ci (thread_start_func_1): store some values before
running thread (to release these after running thread).
* thread_win32.ci (native_thread_create): fix spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_win32.ci')
-rw-r--r-- | thread_win32.ci | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/thread_win32.ci b/thread_win32.ci index dd9a24aad1..29a8efd42c 100644 --- a/thread_win32.ci +++ b/thread_win32.ci @@ -201,29 +201,42 @@ native_mutex_initialize(rb_thread_lock_t *lock) #endif } +void +native_mutex_destroy(rb_thread_lock_t *lock) +{ + CloseHandle(lock); +} + + NOINLINE(static int thread_start_func_2(rb_thread_t *th, VALUE *stack_start)); -void static thread_cleanup_func(void *th_ptr); + +static void +native_thread_destroy(rb_thread_t *th) +{ + CloseHandle(th->native_thread_data.interrupt_event); +} static unsigned int _stdcall thread_start_func_1(void *th_ptr) { rb_thread_t *th = th_ptr; VALUE stack_start; + HANDLE thread_id = th->thread_id; + HANDLE interrupt_event; /* run */ - th->native_thread_data.interrupt_event = CreateEvent(0, TRUE, FALSE, 0); + interrupt_event = th->native_thread_data.interrupt_event = CreateEvent(0, TRUE, FALSE, 0); 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); - thread_cleanup_func(th); /* native_mutex_unlock(&GET_VM()->global_interpreter_lock); */ thread_debug("close handle - intr: %p, thid: %p\n", - th->native_thread_data.interrupt_event, th->thread_id); - CloseHandle(th->native_thread_data.interrupt_event); - CloseHandle(th->thread_id); + interrupt_event, thread_id); + CloseHandle(interrupt_event); + CloseHandle(thread_id); thread_debug("thread deleted (th: %p)\n", th); return 0; } @@ -246,11 +259,11 @@ w32_create_thread(DWORD stack_size, void *func, void *val) static int native_thread_create(rb_thread_t *th) { - size_t stack_size = 4 * 1024 - sizeof(int); /* 4KB */ + size_t stack_size = 4 * 1024; /* 4KB */ + th->thread_id = w32_create_thread(stack_size, thread_start_func_1, th); - if ((th->thread_id = - w32_create_thread(stack_size, thread_start_func_1, th)) - == 0) { + if ((th->thread_id) == 0) { + st_delete_wrap(th->vm->living_threads, th->self); rb_raise(rb_eThreadError, "can't create Thread (%d)", errno); } if (THREAD_DEBUG) { |