summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-13 09:29:13 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-13 09:29:13 +0000
commit6b1bae96414470aba86b8ba7a5822d7d634da8d9 (patch)
tree269e97cf901bc8743662722784544fbc884320f0 /thread.c
parent80323714621e71c2e379a6c20db310f584ddb72e (diff)
* thread.c (rb_mutex_unlock_th): simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/thread.c b/thread.c
index cd7676364b..55ba49d62b 100644
--- a/thread.c
+++ b/thread.c
@@ -3523,7 +3523,6 @@ static const char *
rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t volatile *th)
{
const char *err = NULL;
- rb_mutex_t *th_mutex;
native_mutex_lock(&mutex->lock);
@@ -3542,21 +3541,11 @@ rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t volatile *th)
native_mutex_unlock(&mutex->lock);
if (!err) {
- th_mutex = th->keeping_mutexes;
- if (th_mutex == mutex) {
- th->keeping_mutexes = mutex->next_mutex;
- }
- else {
- while (1) {
- rb_mutex_t *tmp_mutex;
- tmp_mutex = th_mutex->next_mutex;
- if (tmp_mutex == mutex) {
- th_mutex->next_mutex = tmp_mutex->next_mutex;
- break;
- }
- th_mutex = tmp_mutex;
- }
+ rb_mutex_t *volatile *th_mutex = &th->keeping_mutexes;
+ while (*th_mutex != mutex) {
+ th_mutex = &(*th_mutex)->next_mutex;
}
+ *th_mutex = mutex->next_mutex;
mutex->next_mutex = NULL;
}