summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-08 20:24:55 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-08 20:24:55 +0000
commita9026242f2292cc7df06628652f4254c55c37e22 (patch)
tree958b2e49be9f42936803085f5ccadc41d75b2c49 /thread.c
parent990ae267cdc73f954a3fa0b43135f2bbec9f76e8 (diff)
* 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.c')
-rw-r--r--thread.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/thread.c b/thread.c
index a241a41e2c..96ffd2a863 100644
--- a/thread.c
+++ b/thread.c
@@ -247,6 +247,8 @@ thread_cleanup_func(void *th_ptr)
rb_thread_t *th = th_ptr;
th->status = THREAD_KILLED;
th->machine_stack_start = th->machine_stack_end = 0;
+ native_mutex_destroy(&th->interrupt_lock);
+ native_thread_destroy(th);
}
static int
@@ -258,7 +260,6 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start)
rb_thread_t *join_th;
th->machine_stack_start = stack_start;
th->thgroup = th->vm->thgroup_default;
-
thread_debug("thread start: %p\n", th);
native_mutex_lock(&th->vm->global_interpreter_lock);
@@ -297,6 +298,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start)
}
st_delete_wrap(th->vm->living_threads, th->self);
}
+ thread_cleanup_func(th);
native_mutex_unlock(&th->vm->global_interpreter_lock);
return 0;
}
@@ -318,7 +320,6 @@ thread_create_core(VALUE klass, VALUE args, VALUE (*fn)(ANYARGS), void *arg)
th->first_func_arg = arg;
native_mutex_initialize(&th->interrupt_lock);
-
/* kick thread */
st_insert(th->vm->living_threads, thval, (st_data_t) th->thread_id);
native_thread_create(th);
@@ -2082,6 +2083,7 @@ mutex_free(void *ptr)
if (mutex->th) {
native_mutex_unlock(&mutex->lock);
}
+ native_mutex_destroy(&mutex->lock);
}
ruby_xfree(ptr);
}