summaryrefslogtreecommitdiff
path: root/ext/thread
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-26 19:03:21 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-26 19:03:21 +0000
commite9ebc1c8dbf22b8fdb8aa552d6baaf4545e3842c (patch)
treefb90686adddf0d8a8351d73d7410378ea5b32c1d /ext/thread
parent5386d05fb235b59ea301bf035b583e104b9604f8 (diff)
* ext/thread/thread.c (wait_list_cleanup, rb_mutex_try_lock):
Eliminate rb_thread_critical switching where unnecessary; implied by shugo in [ruby-dev:30412]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/thread')
-rw-r--r--ext/thread/thread.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/ext/thread/thread.c b/ext/thread/thread.c
index c9423bd306..354e1445e7 100644
--- a/ext/thread/thread.c
+++ b/ext/thread/thread.c
@@ -247,9 +247,7 @@ static VALUE
wait_list_cleanup(List *list)
{
/* cleanup in case of spurious wakeups */
- rb_thread_critical = 1;
remove_one(list, rb_thread_current());
- rb_thread_critical = 0;
return Qnil;
}
@@ -374,20 +372,14 @@ static VALUE
rb_mutex_try_lock(VALUE self)
{
Mutex *mutex;
- VALUE result;
Data_Get_Struct(self, Mutex, mutex);
- result = Qfalse;
-
- rb_thread_critical = 1;
- if (!RTEST(mutex->owner)) {
- mutex->owner = rb_thread_current();
- result = Qtrue;
- }
- rb_thread_critical = 0;
+ if (RTEST(mutex->owner))
+ return Qfalse;
- return result;
+ mutex->owner = rb_thread_current();
+ return Qtrue;
}
/*