mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (rb_thread_join), ext/thread/thread.c (wake_one): adjusts
targets of rest waiting threads to join. [ruby-core:23457] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@23432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
faa30cafd4
commit
072ccff04d
4 changed files with 102 additions and 2 deletions
|
@ -205,6 +205,16 @@ array_from_list(List const *list)
|
|||
return ary;
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_join(const List *list, VALUE new)
|
||||
{
|
||||
extern void rb_thread_set_join _((VALUE, VALUE));
|
||||
Entry *entry;
|
||||
for (entry = list->entries; entry; entry = entry->next) {
|
||||
rb_thread_set_join(entry->value, new);
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
wake_thread(VALUE thread)
|
||||
{
|
||||
|
@ -221,7 +231,7 @@ run_thread(VALUE thread)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
wake_one(List *list)
|
||||
wake_first(List *list)
|
||||
{
|
||||
VALUE waking;
|
||||
|
||||
|
@ -233,11 +243,23 @@ wake_one(List *list)
|
|||
return waking;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
wake_one(List *list)
|
||||
{
|
||||
VALUE waking = wake_first(list);
|
||||
|
||||
if (!NIL_P(waking)) {
|
||||
adjust_join(list, waking);
|
||||
}
|
||||
|
||||
return waking;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
wake_all(List *list)
|
||||
{
|
||||
while (list->entries) {
|
||||
wake_one(list);
|
||||
wake_first(list);
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue