diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-05-15 08:33:52 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-05-15 08:33:52 +0000 |
commit | 072ccff04debff32072e771bc078fe8bc14ccaad (patch) | |
tree | 8a40c5cffae187dca7a2d507b89b19de037d811d /ext/thread/thread.c | |
parent | faa30cafd475c6f586694910df9767deff97d33e (diff) |
* 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
Diffstat (limited to 'ext/thread/thread.c')
-rw-r--r-- | ext/thread/thread.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/ext/thread/thread.c b/ext/thread/thread.c index 298d7d08ca..b977fa77cf 100644 --- a/ext/thread/thread.c +++ b/ext/thread/thread.c @@ -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; @@ -234,10 +244,22 @@ wake_one(List *list) } 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; } |