* thread.c (thread_create_core): moved failure handling from
native_thread_core(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a360a8ce85
commit
1d4183030d
@ -1,4 +1,7 @@
|
|||||||
Thu Nov 12 13:31:00 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Nov 12 13:57:37 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* thread.c (thread_create_core): moved failure handling from
|
||||||
|
native_thread_core().
|
||||||
|
|
||||||
* thread_pthread.c (native_thread_create): constified.
|
* thread_pthread.c (native_thread_create): constified.
|
||||||
|
|
||||||
|
8
thread.c
8
thread.c
@ -512,6 +512,7 @@ static VALUE
|
|||||||
thread_create_core(VALUE thval, VALUE args, VALUE (*fn)(ANYARGS))
|
thread_create_core(VALUE thval, VALUE args, VALUE (*fn)(ANYARGS))
|
||||||
{
|
{
|
||||||
rb_thread_t *th;
|
rb_thread_t *th;
|
||||||
|
int err;
|
||||||
|
|
||||||
if (OBJ_FROZEN(GET_THREAD()->thgroup)) {
|
if (OBJ_FROZEN(GET_THREAD()->thgroup)) {
|
||||||
rb_raise(rb_eThreadError,
|
rb_raise(rb_eThreadError,
|
||||||
@ -530,7 +531,12 @@ thread_create_core(VALUE thval, VALUE args, VALUE (*fn)(ANYARGS))
|
|||||||
native_mutex_initialize(&th->interrupt_lock);
|
native_mutex_initialize(&th->interrupt_lock);
|
||||||
/* kick thread */
|
/* kick thread */
|
||||||
st_insert(th->vm->living_threads, thval, (st_data_t) th->thread_id);
|
st_insert(th->vm->living_threads, thval, (st_data_t) th->thread_id);
|
||||||
native_thread_create(th);
|
err = native_thread_create(th);
|
||||||
|
if (err) {
|
||||||
|
st_delete_wrap(th->vm->living_threads, th->self);
|
||||||
|
th->status = THREAD_KILLED;
|
||||||
|
rb_raise(rb_eThreadError, "can't create Thread (%d)", err);
|
||||||
|
}
|
||||||
return thval;
|
return thval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,11 +509,6 @@ native_thread_create(rb_thread_t *th)
|
|||||||
if (!err) {
|
if (!err) {
|
||||||
pthread_cond_init(&th->native_thread_data.sleep_cond, 0);
|
pthread_cond_init(&th->native_thread_data.sleep_cond, 0);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
st_delete_wrap(th->vm->living_threads, th->self);
|
|
||||||
th->status = THREAD_KILLED;
|
|
||||||
rb_raise(rb_eThreadError, "can't create Thread (%d)", err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -479,8 +479,7 @@ native_thread_create(rb_thread_t *th)
|
|||||||
th->thread_id = w32_create_thread(stack_size, thread_start_func_1, th);
|
th->thread_id = w32_create_thread(stack_size, thread_start_func_1, th);
|
||||||
|
|
||||||
if ((th->thread_id) == 0) {
|
if ((th->thread_id) == 0) {
|
||||||
st_delete_wrap(th->vm->living_threads, th->self);
|
return errno ? errno : -1;
|
||||||
rb_raise(rb_eThreadError, "can't create Thread (%d)", errno);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
w32_resume_thread(th->thread_id);
|
w32_resume_thread(th->thread_id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user