summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-21 09:06:06 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-21 09:06:06 +0000
commitc79ab68d378cd2ebde4013e2204e0d365fce0b3e (patch)
tree601ae1d9996dbdf96ac617e1277283cb8097aafe /thread.c
parent58b1f91b469fddbe52e280bc044d7c0594bca6d0 (diff)
* vm.c: fix to recycle thread data (VM stack).
* thread.c: ditto. * benchmark/bm_vm3_thread_create_join.rb: add loop count. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/thread.c b/thread.c
index 1655ce0548..6955d86829 100644
--- a/thread.c
+++ b/thread.c
@@ -288,6 +288,7 @@ thread_cleanup_func(void *th_ptr)
extern void ruby_error_print(void);
static VALUE rb_thread_raise(int, VALUE *, rb_thread_t *);
+void rb_thread_recycle_stack_release(VALUE *);
static int
thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_start)
@@ -359,6 +360,11 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
join_th = join_th->join_list_next;
}
st_delete_wrap(th->vm->living_threads, th->self);
+
+ if (!th->root_fiber) {
+ rb_thread_recycle_stack_release(th->stack);
+ th->stack = 0;
+ }
}
thread_cleanup_func(th);
native_mutex_unlock(&th->vm->global_interpreter_lock);
@@ -428,7 +434,6 @@ thread_join(rb_thread_t *target_th, double delay)
th->join_list_next = target_th->join_list_head;
target_th->join_list_head = th;
}
-
while (target_th->status != THREAD_KILLED) {
if (delay == DELAY_INFTY) {
sleep_forever(th);